org.geotools.feature.SchemaException Java Examples
The following examples show how to use
org.geotools.feature.SchemaException.
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: WFSSpatialTest.java From geowave with Apache License 2.0 | 6 votes |
@Before public void setup() throws SchemaException, CQLException, IOException, GeoWavePluginException { dataStore = createDataStore(); type = DataUtilities.createType( "geostuff", "geometry:Geometry:srid=4326,pop:java.lang.Long,when:Date,pid:String"); dataStore.createSchema(type); query = new Query( "geostuff", CQL.toFilter( "BBOX(geometry,27.20,41.30,27.30,41.20) and when during 2005-05-19T20:32:56Z/2005-05-19T21:32:56Z"), new String[] {"geometry", "pid"}); }
Example #2
Source File: JsonDefinitionColumnVisibilityManagementTest.java From geowave with Apache License 2.0 | 6 votes |
@Before public void setup() throws SchemaException, CQLException { type = DataUtilities.createType( "geostuff", "geometry:Geometry:srid=4326,vis:java.lang.String,pop:java.lang.Long,pid:String"); descriptors = type.getAttributeDescriptors(); defaults = new Object[descriptors.size()]; int p = 0; for (final AttributeDescriptor descriptor : descriptors) { defaults[p++] = descriptor.getDefaultValue(); } newFeature = SimpleFeatureBuilder.build(type, defaults, UUID.randomUUID().toString()); newFeature.setAttribute("pop", Long.valueOf(100)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("vis", "{\"pid\":\"TS\", \"geo.*\":\"S\"}"); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 128.232))); }
Example #3
Source File: AttributesSubsetQueryIT.java From geowave with Apache License 2.0 | 6 votes |
private static SimpleFeatureType getSimpleFeatureType() { SimpleFeatureType type = null; try { type = DataUtilities.createType( "testCityData", CITY_ATTRIBUTE + ":String," + STATE_ATTRIBUTE + ":String," + POPULATION_ATTRIBUTE + ":Double," + LAND_AREA_ATTRIBUTE + ":Double," + GEOMETRY_ATTRIBUTE + ":Geometry"); } catch (final SchemaException e) { LOGGER.error("Unable to create SimpleFeatureType", e); } return type; }
Example #4
Source File: QueryOptionsIT.java From geowave with Apache License 2.0 | 6 votes |
private static SimpleFeatureType getSimpleFeatureType(final String typeName) { SimpleFeatureType type = null; try { type = DataUtilities.createType( typeName, CITY_ATTRIBUTE + ":String," + STATE_ATTRIBUTE + ":String," + POPULATION_ATTRIBUTE + ":Double," + LAND_AREA_ATTRIBUTE + ":Double," + GEOMETRY_ATTRIBUTE + ":Geometry"); } catch (final SchemaException e) { System.out.println("Unable to create SimpleFeatureType"); } return type; }
Example #5
Source File: GeoWaveGeoIndexer.java From rya with Apache License 2.0 | 6 votes |
private static SimpleFeatureType getStatementFeatureType(final DataStore dataStore) throws IOException, SchemaException { SimpleFeatureType featureType; final String[] datastoreFeatures = dataStore.getTypeNames(); if (Arrays.asList(datastoreFeatures).contains(FEATURE_NAME)) { featureType = dataStore.getSchema(FEATURE_NAME); } else { featureType = DataUtilities.createType(FEATURE_NAME, SUBJECT_ATTRIBUTE + ":String," + PREDICATE_ATTRIBUTE + ":String," + OBJECT_ATTRIBUTE + ":String," + CONTEXT_ATTRIBUTE + ":String," + GEOMETRY_ATTRIBUTE + ":Geometry:srid=4326," + GEO_ID_ATTRIBUTE + ":String"); dataStore.createSchema(featureType); } return featureType; }
Example #6
Source File: SimpleFeatureCentroidExractorTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void test() throws SchemaException { final SimpleFeatureType schema = DataUtilities.createType("testGeo", "location:Point:srid=4326,name:String"); final List<AttributeDescriptor> descriptors = schema.getAttributeDescriptors(); final Object[] defaults = new Object[descriptors.size()]; int p = 0; for (final AttributeDescriptor descriptor : descriptors) { defaults[p++] = descriptor.getDefaultValue(); } final SimpleFeature feature = SimpleFeatureBuilder.build(schema, defaults, UUID.randomUUID().toString()); final GeometryFactory geoFactory = new GeometryFactory(); feature.setAttribute("location", geoFactory.createPoint(new Coordinate(-45, 45))); final Point point = extractor.getCentroid(feature); assertEquals(4326, point.getSRID()); }
Example #7
Source File: GeoMesaGeoIndexer.java From rya with Apache License 2.0 | 6 votes |
private void initInternal() throws IOException { validPredicates = ConfigUtils.getGeoPredicates(conf); final DataStore dataStore = createDataStore(conf); try { featureType = getStatementFeatureType(dataStore); } catch (final IOException | SchemaException e) { throw new IOException(e); } featureSource = dataStore.getFeatureSource(featureType.getName()); if (!(featureSource instanceof FeatureStore)) { throw new IllegalStateException("Could not retrieve feature store"); } featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>) featureSource; }
Example #8
Source File: GeoMesaGeoIndexer.java From rya with Apache License 2.0 | 6 votes |
private static SimpleFeatureType getStatementFeatureType(final DataStore dataStore) throws IOException, SchemaException { SimpleFeatureType featureType; final String[] datastoreFeatures = dataStore.getTypeNames(); if (Arrays.asList(datastoreFeatures).contains(FEATURE_NAME)) { featureType = dataStore.getSchema(FEATURE_NAME); } else { final String featureSchema = SUBJECT_ATTRIBUTE + ":String," // + PREDICATE_ATTRIBUTE + ":String," // + OBJECT_ATTRIBUTE + ":String," // + CONTEXT_ATTRIBUTE + ":String," // + GEOMETRY_ATTRIBUTE + ":Geometry:srid=4326;geomesa.mixed.geometries='true'"; featureType = SimpleFeatureTypes.createType(FEATURE_NAME, featureSchema); dataStore.createSchema(featureType); } return featureType; }
Example #9
Source File: TimeDescriptorsTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void testOneTime() throws SchemaException { final SimpleFeatureType schema = DataUtilities.createType( "sp.geostuff", "geometry:Geometry:srid=4326,pop:java.lang.Long,when:Date,whennot:Date,pid:String"); final TimeDescriptorConfiguration timeConfig = new TimeDescriptorConfiguration(); timeConfig.configureFromType(schema); final TimeDescriptors td = new TimeDescriptors(schema, timeConfig); assertEquals("when", td.getTime().getLocalName()); assertNull(td.getStartRange()); assertNull(td.getEndRange()); assertTrue(td.hasTime()); }
Example #10
Source File: FeatureDataAdapterTest.java From geowave with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Before public void setup() throws SchemaException, CQLException, ParseException { time1 = DateUtilities.parseISO("2005-05-19T18:33:55Z"); time2 = DateUtilities.parseISO("2005-05-19T19:33:55Z"); schema = DataUtilities.createType( "sp.geostuff", "geometry:Geometry:srid=4326,pop:java.lang.Long,when:Date,whennot:Date,pid:String"); newFeature = FeatureDataUtils.buildFeature( schema, new Pair[] { Pair.of("geometry", factory.createPoint(new Coordinate(27.25, 41.25))), Pair.of("pop", Long.valueOf(100)), Pair.of("when", time1), Pair.of("whennot", time2)}); }
Example #11
Source File: FeatureWritable.java From geowave with Apache License 2.0 | 6 votes |
@Override public void readFields(final DataInput input) throws IOException { try { final String ns = input.readUTF(); featureType = FeatureDataUtils.decodeType( "-".equals(ns) ? "" : ns, input.readUTF(), input.readUTF(), input.readUTF()); } catch (final SchemaException e) { throw new IOException("Failed to parse the encoded feature type", e); } final SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType); // read the fid final String fid = input.readUTF(); // read the other attributes, build the feature for (final AttributeDescriptor ad : featureType.getAttributeDescriptors()) { final Object att = readAttribute(ad, input); builder.add(att); } // build the feature feature = builder.buildFeature(fid); }
Example #12
Source File: FeatureHyperLogLogStaticticsTest.java From geowave with Apache License 2.0 | 5 votes |
@Before public void setup() throws SchemaException, CQLException, ParseException { schema = DataUtilities.createType("sp.geostuff", "geometry:Geometry:srid=4326,pid:String"); dataAdapter = new FeatureDataAdapter( schema, new GlobalVisibilityHandler<SimpleFeature, Object>("default")); }
Example #13
Source File: TimeDescriptorsTest.java From geowave with Apache License 2.0 | 5 votes |
@Test public void testRangeTime() throws SchemaException { final SimpleFeatureType schema = DataUtilities.createType( "sp.geostuff", "geometry:Geometry:srid=4326,pop:java.lang.Long,start:Date,end:Date,pid:String"); final TimeDescriptorConfiguration timeConfig = new TimeDescriptorConfiguration(); timeConfig.configureFromType(schema); final TimeDescriptors td = new TimeDescriptors(schema, timeConfig); assertEquals("start", td.getStartRange().getLocalName()); assertEquals("end", td.getEndRange().getLocalName()); assertNull(td.getTime()); assertTrue(td.hasTime()); }
Example #14
Source File: GeoWaveAvroFeatureDataAdapterTest.java From geowave with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Before public void setup() throws SchemaException, CQLException, ParseException { final StoreFactoryFamilySpi storeFactoryFamily = new MemoryStoreFactoryFamily(); final StoreFactoryOptions opts = storeFactoryFamily.getDataStoreFactory().createOptionsInstance(); opts.setGeoWaveNamespace("test_avro"); dataStore = storeFactoryFamily.getDataStoreFactory().createStore(opts); try { time1 = DateUtilities.parseISO("2005-05-19T18:33:55Z"); time2 = DateUtilities.parseISO("2005-05-19T19:33:55Z"); schema = DataUtilities.createType( "sp.geostuff", "geometry:Geometry:srid=4326,pop:java.lang.Long,when:Date,whennot:Date,pid:String"); // typeBuilder.buildFeatureType(); newFeature = FeatureDataUtils.buildFeature( schema, new Pair[] { Pair.of("geometry", factory.createPoint(new Coordinate(27.25, 41.25))), Pair.of("pop", Long.valueOf(100)), Pair.of("when", time1), Pair.of("whennot", time2)}); } catch (final Exception e) { e.printStackTrace(); } }
Example #15
Source File: FeatureDataAdapterTest.java From geowave with Apache License 2.0 | 5 votes |
@Test public void testDifferentProjection() throws SchemaException { final SimpleFeatureType schema = DataUtilities.createType("sp.geostuff", "geometry:Geometry:srid=3005,pop:java.lang.Long"); final FeatureDataAdapter dataAdapter = new FeatureDataAdapter( schema, new GlobalVisibilityHandler<SimpleFeature, Object>("default")); final Index spatialIndex = new SpatialDimensionalityTypeProvider().createIndex(new SpatialOptions()); dataAdapter.init(spatialIndex); final CoordinateReferenceSystem crs = dataAdapter.getFeatureType().getCoordinateReferenceSystem(); assertTrue(crs.getIdentifiers().toString().contains("EPSG:4326")); @SuppressWarnings("unchecked") final SimpleFeature newFeature = FeatureDataUtils.buildFeature( schema, new Pair[] { Pair.of("geometry", factory.createPoint(new Coordinate(27.25, 41.25))), Pair.of("pop", Long.valueOf(100))}); final AdapterPersistenceEncoding persistenceEncoding = dataAdapter.encode( newFeature, new SpatialDimensionalityTypeProvider().createIndex( new SpatialOptions()).getIndexModel()); GeometryWrapper wrapper = null; for (final Entry<String, ?> pv : persistenceEncoding.getCommonData().getValues().entrySet()) { if (pv.getValue() instanceof GeometryWrapper) { wrapper = (GeometryWrapper) pv.getValue(); } } assertNotNull(wrapper); assertEquals(new Coordinate(-138.0, 44.0), wrapper.getGeometry().getCentroid().getCoordinate()); }
Example #16
Source File: FeatureNumericHistogramStaticticsTest.java From geowave with Apache License 2.0 | 5 votes |
@Before public void setup() throws SchemaException, CQLException, ParseException { schema = DataUtilities.createType( "sp.geostuff", "geometry:Geometry:srid=4326,pop:java.lang.Long,when:Date,whennot:Date,somewhere:Polygon,pid:String"); dataAdapter = new FeatureDataAdapter( schema, new GlobalVisibilityHandler<SimpleFeature, Object>("default")); }
Example #17
Source File: TimeDescriptorsTest.java From geowave with Apache License 2.0 | 5 votes |
@Test public void testWhenAndEndTime() throws SchemaException { final SimpleFeatureType schema = DataUtilities.createType( "sp.geostuff", "geometry:Geometry:srid=4326,pop:java.lang.Long,when:Date,end:Date,pid:String"); final TimeDescriptorConfiguration timeConfig = new TimeDescriptorConfiguration(); timeConfig.configureFromType(schema); final TimeDescriptors td = new TimeDescriptors(schema, timeConfig); assertEquals("when", td.getTime().getLocalName()); assertNull(td.getStartRange()); assertNull(td.getEndRange()); assertTrue(td.hasTime()); }
Example #18
Source File: StatsManagerTest.java From geowave with Apache License 2.0 | 5 votes |
@Before public void setup() throws SchemaException, CQLException, ParseException { schema = DataUtilities.createType( "sp.geostuff", "geometry:Geometry:srid=4326,pop:java.lang.Long,when:Date,whennot:Date,somewhere:Polygon,pid:String"); dataAdapter = new InternalDataAdapterWrapper<>( new FeatureDataAdapter( schema, new GlobalVisibilityHandler<SimpleFeature, Object>("default")), (short) -1); }
Example #19
Source File: FeatureCountMinSketchStaticticsTest.java From geowave with Apache License 2.0 | 5 votes |
@Before public void setup() throws SchemaException, CQLException, ParseException { schema = DataUtilities.createType("sp.geostuff", "geometry:Geometry:srid=4326,pid:String"); dataAdapter = new FeatureDataAdapter( schema, new GlobalVisibilityHandler<SimpleFeature, Object>("default")); }
Example #20
Source File: TimeDescriptorsTest.java From geowave with Apache License 2.0 | 5 votes |
@Test public void testMixedTime() throws SchemaException { final SimpleFeatureType schema = DataUtilities.createType( "sp.geostuff", "geometry:Geometry:srid=4326,pop:java.lang.Long,when:Date,start:Date,end:Date,pid:String"); final TimeDescriptorConfiguration timeConfig = new TimeDescriptorConfiguration(); timeConfig.configureFromType(schema); final TimeDescriptors td = new TimeDescriptors(schema, timeConfig); assertEquals("start", td.getStartRange().getLocalName()); assertEquals("end", td.getEndRange().getLocalName()); assertNull(td.getTime()); assertTrue(td.hasTime()); }
Example #21
Source File: TimeDescriptorsTest.java From geowave with Apache License 2.0 | 5 votes |
@Test public void testJustStartTime() throws SchemaException { final SimpleFeatureType schema = DataUtilities.createType( "sp.geostuff", "geometry:Geometry:srid=4326,pop:java.lang.Long,start:Date,pid:String"); final TimeDescriptorConfiguration timeConfig = new TimeDescriptorConfiguration(); timeConfig.configureFromType(schema); final TimeDescriptors td = new TimeDescriptors(schema, timeConfig); assertEquals("start", td.getTime().getLocalName()); assertNull(td.getStartRange()); assertNull(td.getEndRange()); assertTrue(td.hasTime()); }
Example #22
Source File: TimeDescriptorsTest.java From geowave with Apache License 2.0 | 5 votes |
@Test public void testJustEndTime() throws SchemaException { final SimpleFeatureType schema = DataUtilities.createType( "sp.geostuff", "geometry:Geometry:srid=4326,pop:java.lang.Long,end:Date,pid:String"); final TimeDescriptorConfiguration timeConfig = new TimeDescriptorConfiguration(); timeConfig.configureFromType(schema); final TimeDescriptors td = new TimeDescriptors(schema, timeConfig); assertEquals("end", td.getTime().getLocalName()); assertNull(td.getStartRange()); assertNull(td.getEndRange()); assertTrue(td.hasTime()); }
Example #23
Source File: FilterToCQLToolTest.java From geowave with Apache License 2.0 | 5 votes |
@Before public void setup() throws SchemaException, CQLException { type = DataUtilities.createType( "geostuff", "geom:Geometry:srid=4326,pop:java.lang.Long,pid:String"); }
Example #24
Source File: TimeDescriptorsTest.java From geowave with Apache License 2.0 | 5 votes |
@Test public void testWhenAndStartTime() throws SchemaException { final SimpleFeatureType schema = DataUtilities.createType( "sp.geostuff", "geometry:Geometry:srid=4326,pop:java.lang.Long,when:Date,start:Date,pid:String"); final TimeDescriptorConfiguration timeConfig = new TimeDescriptorConfiguration(); timeConfig.configureFromType(schema); final TimeDescriptors td = new TimeDescriptors(schema, timeConfig); assertEquals("when", td.getTime().getLocalName()); assertNull(td.getStartRange()); assertNull(td.getEndRange()); assertTrue(td.hasTime()); }
Example #25
Source File: FeatureDataUtilsTest.java From geowave with Apache License 2.0 | 5 votes |
@Test public void testWithSRID() throws SchemaException { final SimpleFeatureType type = FeatureDataUtils.decodeType( "http://somens.org", "type1", "geometry:Geometry:srid=4326,pop:java.lang.Long,when:Date,whennot:Date,pid:String", "east"); assertEquals("type1", type.getName().getLocalPart()); }
Example #26
Source File: FeatureDataUtilsTest.java From geowave with Apache License 2.0 | 5 votes |
/** * This test only works in some versions. So, comment out for now. * * <p> public void testWithSRIDAndMisMatch() throws SchemaException { SimpleFeatureType type = * FeatureDataUtils.decodeType("http://somens.org", "type1", * "geometry:Geometry:srid=4326,pop:java.lang.Long,when:Date,whennot:Date,pid:String" , "north"); * assertEquals("type1",type.getName().getLocalPart()); assertEquals * ("NORTH",type.getCoordinateReferenceSystem().getCoordinateSystem * ().getAxis(0).getDirection().name()); } */ @Test public void testWithoutSRID() throws SchemaException { final SimpleFeatureType type = FeatureDataUtils.decodeType( "http://somens.org", "type1", "geometry:Geometry,pop:java.lang.Long,when:Date,whennot:Date,pid:String", StringUtils.stringFromBinary(new byte[0])); assertEquals("type1", type.getName().getLocalPart()); }
Example #27
Source File: FeatureSerializationTest.java From geowave with Apache License 2.0 | 5 votes |
@Test public void test() throws SchemaException { final Kryo kryo = new Kryo(); kryo.register(SimpleFeatureImpl.class, new FeatureSerializer()); final SimpleFeatureType schema = DataUtilities.createType("testGeo", "location:Point:srid=4326,name:String"); final List<AttributeDescriptor> descriptors = schema.getAttributeDescriptors(); final Object[] defaults = new Object[descriptors.size()]; int p = 0; for (final AttributeDescriptor descriptor : descriptors) { defaults[p++] = descriptor.getDefaultValue(); } final SimpleFeature feature = SimpleFeatureBuilder.build(schema, defaults, UUID.randomUUID().toString()); final GeometryFactory geoFactory = new GeometryFactory(); feature.setAttribute("location", geoFactory.createPoint(new Coordinate(-45, 45))); final Output output = new OutputChunked(); kryo.getSerializer(SimpleFeatureImpl.class).write(kryo, output, feature); final Input input = new InputChunked(); input.setBuffer(output.getBuffer()); final SimpleFeature f2 = (SimpleFeature) kryo.getSerializer(SimpleFeatureImpl.class).read( kryo, input, SimpleFeatureImpl.class); assertEquals(feature, f2); }
Example #28
Source File: PolygonDataIdQueryIT.java From geowave with Apache License 2.0 | 5 votes |
private static SimpleFeatureType getSimpleFeatureType() { SimpleFeatureType type = null; try { type = DataUtilities.createType("data", GEOMETRY_ATTRIBUTE + ":Geometry"); } catch (final SchemaException e) { LOGGER.error("Unable to create SimpleFeatureType", e); } return type; }
Example #29
Source File: LegendGraphicServiceImpl.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
private SimpleFeature createSampleFeature(VectorLayer vectorLayer) { SimpleFeatureType type; try { String geomName = "the_geom"; if (vectorLayer != null) { geomName = vectorLayer.getLayerInfo().getFeatureInfo().getGeometryType().getName(); } type = DataUtilities.createType("Sample", geomName + ":Geometry"); } catch (SchemaException e) { throw new IllegalStateException(e.getMessage(), e); } return SimpleFeatureBuilder.template(type, null); }
Example #30
Source File: WFSBoundedQueryTest.java From geowave with Apache License 2.0 | 5 votes |
@Before public void setup() throws SchemaException, CQLException, IOException, GeoWavePluginException { dataStore = createDataStore(); type = DataUtilities.createType( "geostuff", "geometry:Geometry:srid=4326,pop:java.lang.Long,pid:String,when:Date"); dataStore.createSchema(type); }