Java Code Examples for org.geotools.feature.simple.SimpleFeatureTypeBuilder#setDefaultGeometry()
The following examples show how to use
org.geotools.feature.simple.SimpleFeatureTypeBuilder#setDefaultGeometry() .
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: ImportTrackAction.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
private static SimpleFeatureType createTrackFeatureType(GeoCoding geoCoding) { SimpleFeatureTypeBuilder ftb = new SimpleFeatureTypeBuilder(); ftb.setName("org.esa.snap.TrackPoint"); /*0*/ ftb.add("pixelPos", Point.class, geoCoding.getImageCRS()); /*1*/ ftb.add("geoPos", Point.class, DefaultGeographicCRS.WGS84); /*2*/ ftb.add("data", Double.class); ftb.setDefaultGeometry(geoCoding instanceof CrsGeoCoding ? "geoPos" : "pixelPos"); // GeoTools Bug: this doesn't work // ftb.userData("trackPoints", "true"); final SimpleFeatureType ft = ftb.buildFeatureType(); ft.getUserData().put("trackPoints", "true"); return ft; }
Example 2
Source File: ExportGeometryAction.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
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(); }
Example 3
Source File: SimpleFeaturePointFigureTest.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private static SimpleFeatureType createShipTrackFeatureType() { SimpleFeatureTypeBuilder ftb = new SimpleFeatureTypeBuilder(); DefaultGeographicCRS crs = DefaultGeographicCRS.WGS84; ftb.setCRS(crs); ftb.setName("ShipTrack"); ftb.add("index", Integer.class); ftb.add("point", Point.class, crs); ftb.add("data", Double.class); ftb.setDefaultGeometry("point"); return ftb.buildFeatureType(); }
Example 4
Source File: FeatureFigureEditorApp.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private SimpleFeatureType createSimpleFeatureType(String typeName, Class<?> geometryType, SimpleFeatureType defaults) { SimpleFeatureTypeBuilder sftb = new SimpleFeatureTypeBuilder(); if (defaults != null) { //sftb.init(defaults); } DefaultGeographicCRS crs = DefaultGeographicCRS.WGS84; sftb.setCRS(crs); sftb.setName(typeName); sftb.add("geom", geometryType); sftb.add("style", String.class); sftb.setDefaultGeometry("geom"); return sftb.buildFeatureType(); }
Example 5
Source File: CorrelativeFieldSelectorTest.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private SimpleFeatureType createFeatureType(Class binding) { SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.setName("featureType"); builder.add("chl", Float.class); builder.add("sst", Double.class); builder.add("time", ProductData.UTC.class); builder.add("point", binding); builder.setDefaultGeometry("point"); return builder.buildFeatureType(); }
Example 6
Source File: BandFeatureIterator.java From geowave with Apache License 2.0 | 5 votes |
/** * Default SimpleFeatureTypeBuilder which provides the Bands schema of a Sentinel2 provider. */ public static SimpleFeatureTypeBuilder defaultBandFeatureTypeBuilder(final String typeName) throws NoSuchAuthorityCodeException, FactoryException { final SimpleFeatureTypeBuilder sceneBuilder = SceneFeatureIterator.defaultSceneFeatureTypeBuilder(typeName); final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); typeBuilder.init(sceneBuilder.buildFeatureType()); typeBuilder.setName(typeName); typeBuilder.setDefaultGeometry(SceneFeatureIterator.SHAPE_ATTRIBUTE_NAME); typeBuilder.minOccurs(1).maxOccurs(1).nillable(false).add(BAND_ATTRIBUTE_NAME, String.class); return typeBuilder; }
Example 7
Source File: Stanag4676Utils.java From geowave with Apache License 2.0 | 4 votes |
public static SimpleFeatureType createPointDataType() { final SimpleFeatureTypeBuilder simpleFeatureTypeBuilder = new SimpleFeatureTypeBuilder(); simpleFeatureTypeBuilder.setName(TRACK_POINT); simpleFeatureTypeBuilder.setNamespaceURI(NAMESPACE); final AttributeTypeBuilder attributeTypeBuilder = new AttributeTypeBuilder(); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Point.class).buildDescriptor("geometry")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Point.class).buildDescriptor("DetailGeometry")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(String.class).buildDescriptor("Mission")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(String.class).buildDescriptor("TrackNumber")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(String.class).buildDescriptor("TrackUUID")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(String.class).buildDescriptor("TrackItemUUID")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(String.class).buildDescriptor("TrackPointSource")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Date.class).buildDescriptor("TimeStamp")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("Speed")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("Course")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(String.class).buildDescriptor("Classification")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("Latitude")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("Longitude")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("Elevation")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("DetailLatitude")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("DetailLongitude")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("DetailElevation")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Integer.class).buildDescriptor("FrameNumber")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Integer.class).buildDescriptor("PixelRow")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Integer.class).buildDescriptor("PixelColumn")); simpleFeatureTypeBuilder.setDefaultGeometry("geometry"); final TimeDescriptorConfiguration timeConfig = new TimeDescriptorConfiguration(); timeConfig.setTimeName("TimeStamp"); final SimpleFeatureType type = simpleFeatureTypeBuilder.buildFeatureType(); timeConfig.updateType(type); return type; }
Example 8
Source File: Stanag4676Utils.java From geowave with Apache License 2.0 | 4 votes |
public static SimpleFeatureType createTrackDataType() { final SimpleFeatureTypeBuilder simpleFeatureTypeBuilder = new SimpleFeatureTypeBuilder(); simpleFeatureTypeBuilder.setName(TRACK); simpleFeatureTypeBuilder.setNamespaceURI(NAMESPACE); final AttributeTypeBuilder attributeTypeBuilder = new AttributeTypeBuilder(); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(LineString.class).buildDescriptor("geometry")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(LineString.class).buildDescriptor("DetailGeometry")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(String.class).buildDescriptor("Mission")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(String.class).buildDescriptor("TrackNumber")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(String.class).buildDescriptor("TrackUUID")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Date.class).buildDescriptor("StartTime")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Date.class).buildDescriptor("EndTime")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("Duration")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("MinSpeed")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("MaxSpeed")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("AvgSpeed")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("Distance")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("StartLatitude")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("StartLongitude")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("EndLatitude")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("EndLongitude")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("DetailStartLatitude")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("DetailStartLongitude")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("DetailEndLatitude")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("DetailEndLongitude")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Integer.class).buildDescriptor("PointCount")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Integer.class).buildDescriptor("EventCount")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(String.class).buildDescriptor("TrackStatus")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Integer.class).buildDescriptor("TurnCount")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Integer.class).buildDescriptor("UTurnCount")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Integer.class).buildDescriptor("StopCount")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("StopDuration")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(Double.class).buildDescriptor("AvgStopDuration")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(String.class).buildDescriptor("Classification")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(String.class).buildDescriptor("ObjectClass")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(String.class).buildDescriptor("ObjectClassConf")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(String.class).buildDescriptor("ObjectClassRel")); simpleFeatureTypeBuilder.add( attributeTypeBuilder.binding(String.class).buildDescriptor("ObjectClassTime")); simpleFeatureTypeBuilder.setDefaultGeometry("geometry"); final TimeDescriptorConfiguration timeConfig = new TimeDescriptorConfiguration(); timeConfig.setStartRangeName("StartTime"); timeConfig.setEndRangeName("EndTime"); final SimpleFeatureType type = simpleFeatureTypeBuilder.buildFeatureType(); timeConfig.updateType(type); return type; }
Example 9
Source File: SceneFeatureIterator.java From geowave with Apache License 2.0 | 4 votes |
/** * Default SimpleFeatureTypeBuilder which provides the Scene schema of a Sentinel2 repository. */ public static SimpleFeatureTypeBuilder defaultSceneFeatureTypeBuilder(final String typeName) throws NoSuchAuthorityCodeException, FactoryException { final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); typeBuilder.setName(typeName); typeBuilder.setCRS(CRS.decode("EPSG:4326", true)); typeBuilder.setDefaultGeometry(SHAPE_ATTRIBUTE_NAME); // shape (Geometry), // entityId (String), provider (String), location (String), // productIdentifier (String), // productType (String), collection (String), platform (String), // processingLevel (String), startDate (Date), quicklook (String), // thumbnail (String), // bands (String), resolution (Integer), // cloudCover (Integer), snowCover (Integer), waterCover (Integer), // orbitNumber (Integer), relativeOrbitNumber (Integer), // and the feature ID is entityId for the scene // typeBuilder.add(SHAPE_ATTRIBUTE_NAME, Polygon.class); typeBuilder.minOccurs(1).maxOccurs(1).nillable(false).add( ENTITY_ID_ATTRIBUTE_NAME, String.class); typeBuilder.minOccurs(1).maxOccurs(1).nillable(false).add( PROVIDER_NAME_ATTRIBUTE_NAME, String.class); typeBuilder.minOccurs(1).maxOccurs(1).nillable(false).add( LOCATION_ATTRIBUTE_NAME, String.class); typeBuilder.minOccurs(1).maxOccurs(1).nillable(false).add( PRODUCT_ID_ATTRIBUTE_NAME, String.class); typeBuilder.minOccurs(1).maxOccurs(1).nillable(false).add( PRODUCT_TYPE_ATTRIBUTE_NAME, String.class); typeBuilder.minOccurs(1).maxOccurs(1).nillable(false).add( COLLECTION_ATTRIBUTE_NAME, String.class); typeBuilder.minOccurs(1).maxOccurs(1).nillable(false).add( PLATFORM_ATTRIBUTE_NAME, String.class); typeBuilder.add(PROCESSING_LEVEL_ATTRIBUTE_NAME, String.class); typeBuilder.add(ACQUISITION_DATE_ATTRIBUTE_NAME, Date.class); typeBuilder.add(QUICKLOOK_ATTRIBUTE_NAME, String.class); typeBuilder.add(THUMBNAIL_ATTRIBUTE_NAME, String.class); typeBuilder.add(BANDS_ATTRIBUTE_NAME, String.class); typeBuilder.add(RESOLUTION_ATTRIBUTE_NAME, Integer.class); typeBuilder.add(CLOUD_COVER_ATTRIBUTE_NAME, Integer.class); typeBuilder.add(SNOW_COVER_ATTRIBUTE_NAME, Integer.class); typeBuilder.add(WATER_COVER_ATTRIBUTE_NAME, Integer.class); typeBuilder.add(ORBIT_NUMBER_ATTRIBUTE_NAME, Integer.class); typeBuilder.add(RELATIVE_ORBIT_NUMBER_ATTRIBUTE_NAME, Integer.class); typeBuilder.add(SCENE_DOWNLOAD_ATTRIBUTE_NAME, String.class); return typeBuilder; }
Example 10
Source File: InternalFeatureCollection.java From geomajas-project-server with GNU Affero General Public License v3.0 | 4 votes |
private SimpleFeatureType createFeatureType(VectorLayer layer, CoordinateReferenceSystem mapCrs) { SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); VectorLayerInfo info = layer.getLayerInfo(); builder.setName(info.getFeatureInfo().getDataSourceName()); builder.setCRS(mapCrs); for (AbstractAttributeInfo attrInfo : info.getFeatureInfo().getAttributes()) { if (attrInfo instanceof PrimitiveAttributeInfo) { PrimitiveAttributeInfo prim = (PrimitiveAttributeInfo) attrInfo; switch (prim.getType()) { case BOOLEAN: builder.add(prim.getName(), Boolean.class); break; case CURRENCY: builder.add(prim.getName(), BigDecimal.class); break; case DATE: builder.add(prim.getName(), Date.class); break; case DOUBLE: builder.add(prim.getName(), Double.class); break; case FLOAT: builder.add(prim.getName(), Float.class); break; case INTEGER: builder.add(prim.getName(), Integer.class); break; case LONG: builder.add(prim.getName(), Long.class); break; case SHORT: builder.add(prim.getName(), Short.class); break; case STRING: case URL: case IMGURL: builder.add(prim.getName(), String.class); break; default: throw new IllegalStateException("Unknown primitive attribute type " + prim.getType()); } } else if (attrInfo instanceof SyntheticAttributeInfo) { SyntheticAttributeInfo synth = (SyntheticAttributeInfo) attrInfo; // can't determine type, using object builder.add(synth.getName(), Object.class); } } // add the geometry attribute GeometryAttributeInfo geom = info.getFeatureInfo().getGeometryType(); builder.add(geom.getName(), getGeometryBinding(info.getLayerType()), mapCrs); builder.setDefaultGeometry(geom.getName()); return builder.buildFeatureType(); }
Example 11
Source File: CreateSampleDataTest.java From sldeditor with GNU General Public License v3.0 | 3 votes |
/** Test method for {@link com.sldeditor.datasource.impl.CreateSampleData#getDataStore()}. */ @Test public void testGetDataStore() { SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); String typeName = "test type name"; b.setName(typeName); String namespace = null; b.setNamespaceURI(namespace); // add a geometry property b.setCRS(DefaultGeographicCRS.WGS84); // set crs first b.add("the_geom", Polygon.class); b.setDefaultGeometry("the_geom"); // Build the feature type SimpleFeatureType schema = b.buildFeatureType(); CreateSampleData sampleData = new CreateSampleData(); sampleData.create(null, null); sampleData.create(schema, null); DataStore dataStore = sampleData.getDataStore(); assertTrue(dataStore != null); assertEquals(GeometryTypeEnum.POLYGON, sampleData.getGeometryType()); }