@Test public void changeGeometryType() throws Exception { SimpleFeatureType defaultFeatureType = PlainFeatureFactory.createDefaultFeatureType(); assertEquals(Geometry.class, defaultFeatureType.getGeometryDescriptor().getType().getBinding()); SimpleFeatureType changedFeatureType = ExportGeometryAction.changeGeometryType(defaultFeatureType, Polygon.class); assertEquals(Polygon.class, changedFeatureType.getGeometryDescriptor().getType().getBinding()); }
static SimpleFeatureType changeGeometryType(SimpleFeatureType original, Class<?> geometryType) { SimpleFeatureTypeBuilder sftb = new SimpleFeatureTypeBuilder(); sftb.setCRS(original.getCoordinateReferenceSystem()); sftb.setDefaultGeometry(original.getGeometryDescriptor().getLocalName()); boolean defaultGeometryAdded = false; for (AttributeDescriptor descriptor : original.getAttributeDescriptors()) { if (original.getGeometryDescriptor().getLocalName().equals(descriptor.getLocalName())) { sftb.add(descriptor.getLocalName(), geometryType); defaultGeometryAdded = true; }else { sftb.add(descriptor); } } if(!defaultGeometryAdded) { sftb.add(original.getGeometryDescriptor().getLocalName(), geometryType); } sftb.setName("FT_" + geometryType.getSimpleName()); return sftb.buildFeatureType(); }
ExportGeometryAction extends AbstractAction implements ContextAwareAction, LookupListener, HelpCtx.Provider { static SimpleFeatureType changeGeometryType(SimpleFeatureType original, Class<?> geometryType) { SimpleFeatureTypeBuilder sftb = new SimpleFeatureTypeBuilder(); sftb.setCRS(original.getCoordinateReferenceSystem()); sftb.setDefaultGeometry(original.getGeometryDescriptor().getLocalName()); boolean defaultGeometryAdded = false; for (AttributeDescriptor descriptor : original.getAttributeDescriptors()) { if (original.getGeometryDescriptor().getLocalName().equals(descriptor.getLocalName())) { sftb.add(descriptor.getLocalName(), geometryType); defaultGeometryAdded = true; }else { sftb.add(descriptor); } } if(!defaultGeometryAdded) { sftb.add(original.getGeometryDescriptor().getLocalName(), geometryType); } sftb.setName("FT_" + geometryType.getSimpleName()); return sftb.buildFeatureType(); } }
ExportGeometryAction extends AbstractAction implements ContextAwareAction, LookupListener, HelpCtx.Provider { static SimpleFeatureType changeGeometryType(SimpleFeatureType original, Class<?> geometryType) { SimpleFeatureTypeBuilder sftb = new SimpleFeatureTypeBuilder(); sftb.setCRS(original.getCoordinateReferenceSystem()); sftb.setDefaultGeometry(original.getGeometryDescriptor().getLocalName()); boolean defaultGeometryAdded = false; for (AttributeDescriptor descriptor : original.getAttributeDescriptors()) { if (original.getGeometryDescriptor().getLocalName().equals(descriptor.getLocalName())) { sftb.add(descriptor.getLocalName(), geometryType); defaultGeometryAdded = true; }else { sftb.add(descriptor); } } if(!defaultGeometryAdded) { sftb.add(original.getGeometryDescriptor().getLocalName(), geometryType); } sftb.setName("FT_" + geometryType.getSimpleName()); return sftb.buildFeatureType(); } @SuppressWarnings("unused")  ExportGeometryAction();  ExportGeometryAction(Lookup lookup); }
ExportGeometryAction extends AbstractAction implements ContextAwareAction, LookupListener, HelpCtx.Provider { static SimpleFeatureType changeGeometryType(SimpleFeatureType original, Class<?> geometryType) { SimpleFeatureTypeBuilder sftb = new SimpleFeatureTypeBuilder(); sftb.setCRS(original.getCoordinateReferenceSystem()); sftb.setDefaultGeometry(original.getGeometryDescriptor().getLocalName()); boolean defaultGeometryAdded = false; for (AttributeDescriptor descriptor : original.getAttributeDescriptors()) { if (original.getGeometryDescriptor().getLocalName().equals(descriptor.getLocalName())) { sftb.add(descriptor.getLocalName(), geometryType); defaultGeometryAdded = true; }else { sftb.add(descriptor); } } if(!defaultGeometryAdded) { sftb.add(original.getGeometryDescriptor().getLocalName(), geometryType); } sftb.setName("FT_" + geometryType.getSimpleName()); return sftb.buildFeatureType(); } @SuppressWarnings("unused")  ExportGeometryAction();  ExportGeometryAction(Lookup lookup); @Override void actionPerformed(ActionEvent e); @Override HelpCtx getHelpCtx(); @Override Action createContextAwareInstance(Lookup actionContext); @Override void resultChanged(LookupEvent lookupEvent); }
ExportGeometryAction extends AbstractAction implements ContextAwareAction, LookupListener, HelpCtx.Provider { static SimpleFeatureType changeGeometryType(SimpleFeatureType original, Class<?> geometryType) { SimpleFeatureTypeBuilder sftb = new SimpleFeatureTypeBuilder(); sftb.setCRS(original.getCoordinateReferenceSystem()); sftb.setDefaultGeometry(original.getGeometryDescriptor().getLocalName()); boolean defaultGeometryAdded = false; for (AttributeDescriptor descriptor : original.getAttributeDescriptors()) { if (original.getGeometryDescriptor().getLocalName().equals(descriptor.getLocalName())) { sftb.add(descriptor.getLocalName(), geometryType); defaultGeometryAdded = true; }else { sftb.add(descriptor); } } if(!defaultGeometryAdded) { sftb.add(original.getGeometryDescriptor().getLocalName(), geometryType); } sftb.setName("FT_" + geometryType.getSimpleName()); return sftb.buildFeatureType(); } @SuppressWarnings("unused")  ExportGeometryAction();  ExportGeometryAction(Lookup lookup); @Override void actionPerformed(ActionEvent e); @Override HelpCtx getHelpCtx(); @Override Action createContextAwareInstance(Lookup actionContext); @Override void resultChanged(LookupEvent lookupEvent);  }