private Map<String, Object> buildDummyFeatureTypeInfo(ComplexAttribute f) { Map<String, Object> dummy = new HashMap<String, Object>(); dummy.put("name", f.getType().getName().getLocalPart()); dummy.put("namespace", getNamespace(f.getType().getName())); dummy.put("prefix", getPrefix(f.getType().getName())); dummy.put("title", "Layer: " + f.getType().getName().getLocalPart()); dummy.put("abstract", "[No Abstract Provided]"); dummy.put("description", "[No Description Provided]"); dummy.put("keywords", new ArrayList<String>()); dummy.put("metadataLinks", new ArrayList<String>()); dummy.put("SRS", "[SRS]"); if (f instanceof Feature) { final GeometryDescriptor gd = ((Feature) f).getType().getGeometryDescriptor(); if (gd != null) { dummy.put("nativeCRS", gd.getCoordinateReferenceSystem()); } } return dummy; }
@Test public void testForce() throws Exception { FeatureTypeInfo fti = getCatalog().getFeatureTypeByName(MockData.BASIC_POLYGONS.getLocalPart()); assertEquals("EPSG:4269", fti.getSRS()); assertEquals(ProjectionPolicy.FORCE_DECLARED, fti.getProjectionPolicy()); FeatureCollection fc = fti.getFeatureSource(null, null).getFeatures(); assertEquals(CRS.decode("EPSG:4269"), fc.getSchema().getCoordinateReferenceSystem()); FeatureIterator fi = fc.features(); Feature f = fi.next(); fi.close(); assertEquals(CRS.decode("EPSG:4269"), f.getType().getCoordinateReferenceSystem()); }
@Test public void testLeaveNative() throws Exception { FeatureTypeInfo fti = getCatalog().getFeatureTypeByName(MockData.LINES.getLocalPart()); assertEquals("EPSG:3004", fti.getSRS()); assertEquals(ProjectionPolicy.NONE, fti.getProjectionPolicy()); FeatureCollection fc = fti.getFeatureSource(null, null).getFeatures(); assertEquals(CRS.decode("EPSG:32615"), fc.getSchema().getCoordinateReferenceSystem()); FeatureIterator fi = fc.features(); Feature f = fi.next(); // test that the geometry was left in tact Geometry g = (Geometry) f.getDefaultGeometryProperty().getValue(); assertTrue(g.equalsExact(WKT.read("LINESTRING(500125 500025,500175 500075)"))); fi.close(); assertEquals(CRS.decode("EPSG:32615"), f.getType().getCoordinateReferenceSystem()); }
@Test public void testReproject() throws Exception { FeatureTypeInfo fti = getCatalog().getFeatureTypeByName(MockData.POLYGONS.getLocalPart()); assertEquals("EPSG:4326", fti.getSRS()); assertEquals(ProjectionPolicy.REPROJECT_TO_DECLARED, fti.getProjectionPolicy()); FeatureCollection fc = fti.getFeatureSource(null, null).getFeatures(); assertEquals(CRS.decode("EPSG:4326"), fc.getSchema().getCoordinateReferenceSystem()); FeatureIterator fi = fc.features(); Feature f = fi.next(); // test that geometry was actually reprojected Geometry g = (Geometry) f.getDefaultGeometryProperty().getValue(); assertFalse( g.equalsExact( WKT.read( "POLYGON((500225 500025,500225 500075,500275 500050,500275 500025,500225 500025))"))); fi.close(); assertEquals(CRS.decode("EPSG:4326"), f.getType().getCoordinateReferenceSystem()); }
@Test public void testWithRename() throws Exception { FeatureTypeInfo fti = getCatalog().getFeatureTypeByName("MyPoints"); assertEquals("EPSG:4326", fti.getSRS()); assertEquals(ProjectionPolicy.REPROJECT_TO_DECLARED, fti.getProjectionPolicy()); FeatureCollection fc = fti.getFeatureSource(null, null).getFeatures(); assertEquals(CRS.decode("EPSG:4326"), fc.getSchema().getCoordinateReferenceSystem()); FeatureIterator fi = fc.features(); Feature f = fi.next(); // test that geometry was reprojected Geometry g = (Geometry) f.getDefaultGeometryProperty().getValue(); assertFalse(g.equalsExact(WKT.read("POINT(500050 500050)"))); fi.close(); assertEquals(CRS.decode("EPSG:4326"), f.getType().getCoordinateReferenceSystem()); }
/** * Sends sax for the ending of a feature. * * @param f Feature (implementation assume a SimpleFeature) * @throws RuntimeException if something goes wrong during encode it is wrapped up as a * generic runtime exception */ public void endFeature(Feature f) { try { Name typeName = f.getType().getName(); String name = typeName.getLocalPart(); if (currentPrefix != null) { name = currentPrefix + ":" + name; } contentHandler.endElement("", "", name); contentHandler.endElement("", "", memberString); } catch (Exception e) { throw new RuntimeException(e); } }
/** * Simplifies id value, cutting "typename." part if exists * * @param feature * @return */ protected String simplifyIndentifier(Feature feature) { String schemaPart = feature.getType().getName().getLocalPart() + "."; String fid = feature.getIdentifier().getID(); if (fid.startsWith(schemaPart)) { return fid.substring(schemaPart.length()); } return fid; } }
public static Element AbstractFeatureType_encode( Object object, Document document, Element value) { Feature feature = (Feature) object; FeatureType featureType = feature.getType(); String namespace = featureType.getName().getNamespaceURI(); String typeName = featureType.getName().getLocalPart(); Element encoding = document.createElementNS(namespace, typeName); encoding.setAttributeNS(null, "fid", feature.getIdentifier().getID()); return encoding; }
private void setDefaultGeometryAttribute(Feature feature) { String defaultGeomXPath = mapping.getDefaultGeometryXPath(); if (defaultGeomXPath != null && !defaultGeomXPath.isEmpty()) { GeometryDescriptor defaultGeomDescr = feature.getType().getGeometryDescriptor(); if (defaultGeomDescr != null) { PropertyName geomProperty = filterFac.property(defaultGeomXPath, namespaces); Object geomValue = geomProperty.evaluate(feature); if (geomValue instanceof Collection) { throw new RuntimeException( "Error setting default geometry value: multiple values were found"); } String geomName = Types.toPrefixedName(defaultGeomDescr.getName(), namespaces); StepList fakeDefaultGeomXPath = XPath.steps(targetFeature, geomName, namespaces); xpathAttributeBuilder.set( feature, fakeDefaultGeomXPath, geomValue, null, null, false, null); } } }
typeName = feature.getType().getName(); } else {
/** * Visitor function, which looks at each feature and finds the value of the attribute given * attribute nearest to the given comparison value. * * @param feature the feature to be visited */ @SuppressWarnings("unchecked") public void visit(org.opengis.feature.Feature feature) { // bail out immediately if we have already found an exact match if (visited) { return; } if (attributeClass == null) { PropertyDescriptor desc = (PropertyDescriptor) expr.evaluate(feature.getType()); attributeClass = desc.getType().getBinding(); if (accumulator == null) { accumulator = getAccumulator(attributeClass); } } // extract the value Object attribValue = expr.evaluate(feature); if (attribValue == null) { return; } else { visited |= accumulator.visit(attribValue); } }
contentHandler.startElement("", "", memberString, NULL_ATTS); FeatureType type = f.getType(); String name = type.getName().getLocalPart(); String namespaceURI = type.getName().getNamespaceURI();
name = new NameImpl( next.getType().getName().getNamespaceURI(), descriptor.getLocalName());
FeatureType featureType = feature.getType();
/** * Finds the geometric attribute coordinate reference system. * * @param drawMe2 * @param f The feature * @param s The symbolizer * @return The geometry requested in the symbolizer, or the default geometry if none is * specified */ private org.opengis.referencing.crs.CoordinateReferenceSystem findGeometryCS( Feature f, Symbolizer s) { FeatureType schema = f.getType(); Expression geometry = s.getGeometry(); if (geometry instanceof PropertyName) { return getAttributeCRS((PropertyName) geometry, schema); } else if (geometry == null) { return getAttributeCRS(null, schema); } else { StyleAttributeExtractor attExtractor = new StyleAttributeExtractor(); geometry.accept(attExtractor, null); for (PropertyName name : attExtractor.getAttributes()) { if (name.evaluate(schema) instanceof GeometryDescriptor) { return getAttributeCRS(name, schema); } } } return null; }
createTargetFeature( firstFeature, (SimpleFeatureType) firstFeature.getType(), new MultiLineString( (LineString[])
@Before public void setup() { String workspaceName = "workspacename"; expect(mockCatalog.getNamespaceByPrefix(workspaceName)).andReturn(mockNamespaceInfo); expect(mockWorkspaceInfo.getName()).andReturn(workspaceName); expect(mockNamespaceInfo.getURI()).andReturn(WORKSPACE_URI); expect(mockFeature.getType()).andReturn(mockFeatureType); expect(mockFeatureType.getName()).andReturn(mockName); }
public FeatureInfo featureInfo(Feature f) { FeatureType type = f.getType(); String treePath = type.getName().getLocalPart(); return featureInfo(treePath, f); }
assertEquals(targetType, complexFeature.getType());
public FeatureInfo featureInfo(String treePath, Feature f) { final String path = NodeRef.appendChild(treePath, f.getIdentifier().getID()); RevFeature feature = RevFeature.builder().build(f); FeatureType type = f.getType(); RevFeatureType ftype = RevFeatureType.builder().type(type).build(); repo.objectDatabase().put(ftype); return FeatureInfo.insert(feature, ftype.getId(), path); }