Java Code Examples for org.opengis.feature.simple.SimpleFeatureType#getGeometryDescriptor()
The following examples show how to use
org.opengis.feature.simple.SimpleFeatureType#getGeometryDescriptor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ElasticGeometryFilterIT.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testAlternateGeometry() throws Exception { init("active", "geo2"); SimpleFeatureType schema = featureSource.getSchema(); GeometryDescriptor gd = schema.getGeometryDescriptor(); assertNotNull(gd); assertEquals("geo2", gd.getLocalName()); FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory(); BBOX bbox = ff.bbox("geo2", 6.5, 23.5, 7.5, 24.5, "EPSG:4326"); SimpleFeatureCollection features = featureSource.getFeatures(bbox); assertEquals(1, features.size()); SimpleFeatureIterator fsi = features.features(); assertTrue(fsi.hasNext()); assertEquals(fsi.next().getID(), "active.09"); }
Example 2
Source File: GeoWaveGTDataStore.java From geowave with Apache License 2.0 | 6 votes |
@Override public void createSchema(final SimpleFeatureType featureType) { if (featureType.getGeometryDescriptor() == null) { throw new UnsupportedOperationException("Schema missing geometry"); } final FeatureDataAdapter adapter = new FeatureDataAdapter(featureType, visibilityManagement); final short adapterId = internalAdapterStore.addTypeName(adapter.getTypeName()); if (!adapterStore.adapterExists(adapterId)) { // it is questionable whether createSchema *should* write the // adapter to the store, it is missing the proper index information // at this stage adapter.init(new SpatialDimensionalityTypeProvider().createIndex(new SpatialOptions())); if (featureNameSpaceURI != null) { adapter.setNamespace(featureNameSpaceURI.toString()); } final InternalDataAdapter<?> internalAdapter = new InternalDataAdapterWrapper(adapter, adapterId); adapterStore.addAdapter(internalAdapter); } }
Example 3
Source File: FeatureDataUtils.java From geowave with Apache License 2.0 | 6 votes |
public static String getGeomField(final DataStorePluginOptions dataStore, final String typeName) { final PersistentAdapterStore adapterStore = dataStore.createAdapterStore(); final InternalAdapterStore internalAdapterStore = dataStore.createInternalAdapterStore(); final DataTypeAdapter<?> adapter = adapterStore.getAdapter(internalAdapterStore.getAdapterId(typeName)).getAdapter(); if ((adapter != null) && (adapter instanceof GeotoolsFeatureDataAdapter)) { final GeotoolsFeatureDataAdapter gtAdapter = (GeotoolsFeatureDataAdapter) adapter; final SimpleFeatureType featureType = gtAdapter.getFeatureType(); if (featureType.getGeometryDescriptor() != null) { return featureType.getGeometryDescriptor().getLocalName(); } } return null; }
Example 4
Source File: SLDs.java From gama with GNU General Public License v3.0 | 5 votes |
public static final boolean isPolygon(final SimpleFeatureType featureType) { if (featureType == null) { return false; } final GeometryDescriptor geometryType = featureType.getGeometryDescriptor(); if (geometryType == null) { return false; } final Class<?> type = geometryType.getType().getBinding(); return Polygon.class.isAssignableFrom(type) || MultiPolygon.class.isAssignableFrom(type); }
Example 5
Source File: SLDs.java From gama with GNU General Public License v3.0 | 5 votes |
public static final boolean isLine(final SimpleFeatureType featureType) { if (featureType == null) { return false; } final GeometryDescriptor geometryType = featureType.getGeometryDescriptor(); if (geometryType == null) { return false; } final Class<?> type = geometryType.getType().getBinding(); return LineString.class.isAssignableFrom(type) || MultiLineString.class.isAssignableFrom(type); }
Example 6
Source File: SLDs.java From gama with GNU General Public License v3.0 | 5 votes |
public static final boolean isPoint(final SimpleFeatureType featureType) { if (featureType == null) { return false; } final GeometryDescriptor geometryType = featureType.getGeometryDescriptor(); if (geometryType == null) { return false; } final Class<?> type = geometryType.getType().getBinding(); return Point.class.isAssignableFrom(type) || MultiPoint.class.isAssignableFrom(type); }
Example 7
Source File: FeatureDataAdapter.java From geowave with Apache License 2.0 | 5 votes |
/** * Get a List<> of the default index field handlers from the Simple Feature Type provided * * @param typeObj - Simple Feature Type object * @return - List of the default Index Field Handlers */ @Override protected List<IndexFieldHandler<SimpleFeature, ? extends CommonIndexValue, Object>> getDefaultTypeMatchingHandlers( final Object typeObj) { if ((typeObj != null) && (typeObj instanceof SimpleFeatureType)) { final SimpleFeatureType internalType = (SimpleFeatureType) typeObj; final List<IndexFieldHandler<SimpleFeature, ? extends CommonIndexValue, Object>> defaultHandlers = new ArrayList<>(); nativeFieldHandlers = getFieldHandlersFromFeatureType(internalType); // Add default handler for Time final IndexFieldHandler<SimpleFeature, Time, Object> timeHandler = getTimeRangeHandler(internalType); if (timeHandler != null) { defaultHandlers.add(timeHandler); } // Add default handler for Geometry final AttributeDescriptor descriptor = internalType.getGeometryDescriptor(); final VisibilityConfiguration visConfig = new VisibilityConfiguration(internalType); if (descriptor != null) { defaultHandlers.add( new FeatureGeometryHandler( descriptor, visConfig.getManager().createVisibilityHandler( descriptor.getLocalName(), fieldVisiblityHandler, visConfig.getAttributeName()))); } return defaultHandlers; } LOGGER.warn("Simple Feature Type could not be used for handling the indexed data"); return super.getDefaultTypeMatchingHandlers(reprojectedFeatureType); }
Example 8
Source File: OmsScanLineRasterizer.java From hortonmachine with GNU General Public License v3.0 | 4 votes |
@Execute public void process() throws Exception { checkNull(inVector); if (pValue == null && fCat == null) { throw new ModelsIllegalargumentException("One of pValue or the fCat have to be defined.", this, pm); } if (pNorth == null || pSouth == null || pWest == null || pEast == null || pRows == null || pCols == null) { if (inRaster == null) { throw new ModelsIllegalargumentException( "It is necessary to supply all the information about the processing region. Did you set the boundaries and rows/cols?", this, pm); } } if (inRaster != null) { RegionMap regionMap = CoverageUtilities.getRegionParamsFromGridCoverage(inRaster); pNorth = regionMap.getNorth(); pSouth = regionMap.getSouth(); pWest = regionMap.getWest(); pEast = regionMap.getEast(); pRows = regionMap.getRows(); pCols = regionMap.getCols(); inIter = CoverageUtilities.getRandomIterator(inRaster); } SimpleFeatureType schema = inVector.getSchema(); CoordinateReferenceSystem crs = schema.getCoordinateReferenceSystem(); GridGeometry2D pGrid; if (inRaster != null) { pGrid = inRaster.getGridGeometry(); } else { pGrid = gridGeometryFromRegionValues(pNorth, pSouth, pEast, pWest, pCols, pRows, crs); } if (outWR == null) { paramsMap = gridGeometry2RegionParamsMap(pGrid); height = paramsMap.getRows(); width = paramsMap.getCols(); xRes = paramsMap.getXres(); outWR = CoverageUtilities.createWritableRaster(width, height, null, null, doubleNovalue); } GeometryDescriptor geometryDescriptor = schema.getGeometryDescriptor(); if (EGeometryType.isPoint(geometryDescriptor)) { throw new ModelsRuntimeException("Not implemented yet for points", this.getClass().getSimpleName()); } else if (EGeometryType.isLine(geometryDescriptor)) { throw new ModelsRuntimeException("Not implemented yet for lines", this.getClass().getSimpleName()); } else if (EGeometryType.isPolygon(geometryDescriptor)) { if (pUsePointInPolygon) { if (inRaster == null) { throw new ModelsIllegalargumentException("The point in polygon mode needs an input raster to work on.", this); } pm.beginTask("Prepare input data...", IHMProgressMonitor.UNKNOWN); List<Geometry> allGeoms = FeatureUtilities.featureCollectionToGeometriesList(inVector, false, null); Geometry allGeomsUnion = CascadedPolygonUnion.union(allGeoms); PreparedGeometry preparedGeometry = PreparedGeometryFactory.prepare(allGeomsUnion); pm.done(); double value = pValue; pm.beginTask("Rasterizing...", height); WritableRandomIter wIter = CoverageUtilities.getWritableRandomIterator(outWR); for( int row = 0; row < height; row++ ) { for( int col = 0; col < width; col++ ) { Coordinate coord = CoverageUtilities.coordinateFromColRow(col, row, pGrid); if (preparedGeometry.intersects(gf.createPoint(coord))) { wIter.setSample(col, col, 0, value); } } pm.worked(1); } pm.done(); wIter.done(); } else { rasterizepolygon(pGrid); } } else { throw new ModelsIllegalargumentException("Couldn't recognize the geometry type of the file.", this.getClass().getSimpleName(), pm); } outRaster = CoverageUtilities.buildCoverage("rasterized", outWR, paramsMap, inVector.getSchema().getCoordinateReferenceSystem()); }
Example 9
Source File: GeoToolsLayerBeanFactory.java From geomajas-project-server with GNU Affero General Public License v3.0 | 4 votes |
private void setFeatureInfo(VectorLayerInfo info, SimpleFeatureType schema) { FeatureInfo featureInfo = new FeatureInfo(); GeometryAttributeInfo geomInfo = new GeometryAttributeInfo(); geomInfo.setEditable(true); geomInfo.setName(schema.getGeometryDescriptor().getLocalName()); featureInfo.setGeometryType(geomInfo); featureInfo.setDataSourceName(schema.getTypeName()); List<AttributeDescriptor> attrs = schema.getAttributeDescriptors(); for (AttributeDescriptor attributeDescriptor : attrs) { if (attributeDescriptor != schema.getGeometryDescriptor()) { Class<?> binding = attributeDescriptor.getType().getBinding(); PrimitiveAttributeInfo attrInfo = new PrimitiveAttributeInfo(); if (binding == Boolean.class) { attrInfo.setType(PrimitiveType.BOOLEAN); } else if (binding == Short.class) { attrInfo.setType(PrimitiveType.SHORT); } else if (binding == Integer.class) { attrInfo.setType(PrimitiveType.INTEGER); } else if (binding == Long.class) { attrInfo.setType(PrimitiveType.LONG); } else if (binding == Float.class) { attrInfo.setType(PrimitiveType.FLOAT); } else if (binding == Double.class) { attrInfo.setType(PrimitiveType.DOUBLE); } else if (binding == Date.class) { attrInfo.setType(PrimitiveType.DATE); } else if (binding == String.class) { attrInfo.setType(PrimitiveType.STRING); } attrInfo.setEditable(true); attrInfo.setIdentifying(attributeDescriptor.getType().isIdentified()); attrInfo.setLabel(attributeDescriptor.getLocalName()); attrInfo.setName(attributeDescriptor.getLocalName()); if (attributeDescriptor.getType().isIdentified() && featureInfo.getIdentifier() == null) { featureInfo.setIdentifier(attrInfo); } else { featureInfo.getAttributes().add(attrInfo); } } } info.setFeatureInfo(featureInfo); }