crs = resource.getNativeCRS(); } else { crs = resource.getCRS();
void doSetupBounds(ResourceInfo rinfo, Object data) throws IOException { // setup the native bbox if needed if (rinfo.getNativeBoundingBox() == null) { ReferencedEnvelope bounds = getNativeBounds(rinfo, data); rinfo.setNativeBoundingBox(bounds); } // setup the geographic bbox if missing and we have enough info rinfo.setLatLonBoundingBox(getLatLonBounds(rinfo.getNativeBoundingBox(), rinfo.getCRS())); }
private ReferencedEnvelope aggregateEnvelopes(LayerInfo... layers) { ReferencedEnvelope eoExpected = new ReferencedEnvelope( layers[0].getResource().getNativeBoundingBox(), layers[0].getResource().getCRS()); for (int i = 1; i < layers.length; i++) { eoExpected.expandToInclude(layers[i].getResource().getNativeBoundingBox()); } return eoExpected; } }
&& bounds != null) { try { bounds = bounds.transform(rinfo.getCRS(), true); } catch (Exception e) { throw (IOException) new IOException("transform error").initCause(e);
File f = new File ( "world.shp" ); ShapefileDataStore dataStore = new ShapefileDataStore ( f.toURI ().toURL () ); FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = dataStore.getFeatureSource (); String geomAttrName = featureSource.getSchema () .getGeometryDescriptor ().getLocalName (); ResourceInfo resourceInfo = featureSource.getInfo (); CoordinateReferenceSystem crs = resourceInfo.getCRS (); Hints hints = GeoTools.getDefaultHints (); hints.put ( Hints.JTS_SRID, 4326 ); hints.put ( Hints.CRS, crs ); FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2 ( hints ); GeometryFactory gf = JTSFactoryFinder.getGeometryFactory ( hints ); Coordinate land = new Coordinate ( -122.0087, 47.54650 ); Point pointLand = gf.createPoint ( land ); Coordinate water = new Coordinate ( 0, 0 ); Point pointWater = gf.createPoint ( water ); Intersects filter = ff.intersects ( ff.property ( geomAttrName ), ff.literal ( pointLand ) ); FeatureCollection<SimpleFeatureType, SimpleFeature> features = featureSource .getFeatures ( filter ); filter = ff.intersects ( ff.property ( geomAttrName ), ff.literal ( pointWater ) ); features = featureSource.getFeatures ( filter );
/** * Retrieves the native {@link CoordinateReferenceSystem} for the provided {@link ResourceInfo}. * * @param resourceInfo * @return the native {@link CoordinateReferenceSystem} for the provided {@link ResourceInfo}. * @throws IOException in case something bad happems! */ static CoordinateReferenceSystem getNativeCRS(ResourceInfo resourceInfo) throws IOException { // prepare native CRS ProjectionPolicy pp = resourceInfo.getProjectionPolicy(); if (pp == null || pp == ProjectionPolicy.FORCE_DECLARED) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "PropjectionPolicy null or FORCE_DECLARED"); } return resourceInfo.getCRS(); } else { return resourceInfo.getNativeCRS(); } }
public CoordinateReferenceSystem getCoordinateReferenceSystem() { if (layerInfo != null) { return layerInfo.getResource().getCRS(); } if (remoteFeatureSource != null) { SimpleFeatureType schema = remoteFeatureSource.getSchema(); return schema.getCoordinateReferenceSystem(); } throw new IllegalStateException(); }
/** * Maps a layer info to the capabilities json structure. Using a linked hash map under covers to * preserve the order of the attributes * * @param layerInfo * @return * @throws IOException */ private Map toJSON(LayerInfo layerInfo) throws IOException { final ResourceInfo resource = layerInfo.getResource(); try { LinkedHashMap json = new LinkedHashMap(); json.put("name", resource.getPrefixedName()); try { json.put("bbox", toJSON(resource.boundingBox())); } catch(Exception e) { throw ((IOException) new IOException("Failed to get the resource bounding box of:" + resource.getPrefixedName()).initCause(e)); } json.put("crs", "urn:ogc:def:crs:EPSG:" + CRS.lookupEpsgCode(resource.getCRS(), false)); json.put("axisorder", "xy"); return json; } catch (FactoryException e) { throw ((IOException) new IOException("Failed to lookup the EPSG code").initCause(e)); } }
public CoordinateReferenceSystem getDeclaredCrs(final String geoServerTileLayerName) { GeoServerTileLayer layer = (GeoServerTileLayer) getTileLayerByName(geoServerTileLayerName); LayerInfo layerInfo = layer.getLayerInfo(); if (layerInfo != null) { return layerInfo.getResource().getCRS(); } LayerGroupInfo layerGroupInfo = layer.getLayerGroupInfo(); ReferencedEnvelope bounds = layerGroupInfo.getBounds(); return bounds.getCoordinateReferenceSystem(); }
public CoordinateReferenceSystem getDeclaredCrs(final String geoServerTileLayerName) { GeoServerTileLayer layer = (GeoServerTileLayer) getTileLayerByName(geoServerTileLayerName); LayerInfo layerInfo = layer.getLayerInfo(); if (layerInfo != null) { return layerInfo.getResource().getCRS(); } LayerGroupInfo layerGroupInfo = layer.getLayerGroupInfo(); ReferencedEnvelope bounds = layerGroupInfo.getBounds(); return bounds.getCoordinateReferenceSystem(); }
if (nativeCrs == null) { sourceCrs = resource.getCRS(); } else { sourceCrs = nativeCrs;
resourceInfo.getCRS()));
resourceInfo.setNativeBoundingBox(nativeBounds); resourceInfo.setLatLonBoundingBox( cb.getLatLonBounds(nativeBounds, resourceInfo.getCRS()));
CoordinateReferenceSystem resourceCrs = resource.getCRS(); if ((resourceCrs != null) && !CRS.equalsIgnoreMetadata(geomCrs, resourceCrs)) { MathTransform mt = CRS.findMathTransform(geomCrs, resourceCrs, true);
CoordinateReferenceSystem resourceCrs = resource.getCRS(); if ((resourceCrs != null) && !CRS.equalsIgnoreMetadata(geomCrs, resourceCrs)) { MathTransform mt = CRS.findMathTransform(geomCrs, resourceCrs, true);
@Test public void testGetFeatureCRS() throws Exception { QName layer = SystemTestData.LINES; JSONObject collection = (JSONObject) getAsJSON( "wfs?request=GetFeature&version=1.0.0&typename=" + getLayerId(layer) + "&outputformat=" + JSONType.json); CoordinateReferenceSystem expectedCrs = getCatalog().getLayerByName(getLayerId(layer)).getResource().getCRS(); JSONObject aCRS = collection.getJSONObject("crs"); assertThat(aCRS, encodesCRS(expectedCrs)); }
grid.getGridRange(), grid.getGridToCRS(), resourceInfo.getCRS()));
@Test public void testGeometryCollection() throws Exception { String out = getAsString( "wfs?request=GetFeature&version=1.0.0&typename=sf:AggregateGeoFeature&maxfeatures=3&outputformat=" + JSONType.json); JSONObject rootObject = JSONObject.fromObject(out); assertEquals(rootObject.get("type"), "FeatureCollection"); JSONArray featureCol = rootObject.getJSONArray("features"); JSONObject aFeature = featureCol.getJSONObject(1); JSONObject aPropeties = aFeature.getJSONObject("properties"); JSONObject aGeometry = aPropeties.getJSONObject("multiCurveProperty"); assertEquals(aGeometry.getString("type"), "MultiLineString"); JSONArray geomArray = aGeometry.getJSONArray("coordinates"); geomArray = geomArray.getJSONArray(0); geomArray = geomArray.getJSONArray(0); assertEquals(geomArray.getString(0), "55.174"); CoordinateReferenceSystem expectedCrs = getCatalog() .getLayerByName(getLayerId(SystemTestData.AGGREGATEGEOFEATURE)) .getResource() .getCRS(); JSONObject aCRS = rootObject.getJSONObject("crs"); assertThat(aCRS.getString("type"), equalTo("name")); assertThat(aCRS, encodesCRS(expectedCrs)); }
new ProjectionPolicyRenderer()); ResourceInfo ri = (ResourceInfo) model.getObject(); if (((ResourceInfo) model.getObject()).getCRS() == null) {
new ProjectionPolicyRenderer()); ResourceInfo ri = (ResourceInfo) model.getObject(); if (((ResourceInfo) model.getObject()).getCRS() == null) {