@Before public void setUp() throws Exception { System.setProperty("org.geotools.referencing.forceXY", "true"); gmlFileFormat = new GMLFileFormat(); }
@Override public FeatureReader read(ImportData data, ImportTask task) throws IOException { File file = getFileFromData(data); // we need to get the feature type, to use for the particular parse through the file // since we put it on the metadata from the list method, we first check if that's still // available SimpleFeatureType ft = (SimpleFeatureType) task.getMetadata().get(FeatureType.class); GMLVersion version = (GMLVersion) task.getMetadata().get(GML_VERSION_KEY); if (version == null) { version = GMLVersion.GML3; } if (ft == null) { FeatureTypeInfo fti = (FeatureTypeInfo) task.getLayer().getResource(); ft = buildFeatureTypeFromInfo(fti); } return new GMLReader(new FileInputStream(file), version.getConfiguration(), ft); }
@Test public void testParseStreamsGML3() throws Exception { File file = new File( "./src/test/resources/org/geoserver/importer/test-data/gml/streams.gml3.gml"); SimpleFeatureType schema = gmlFileFormat.getSchema(file); assertEquals(MultiLineString.class, schema.getGeometryDescriptor().getType().getBinding()); assertEquals( CRS.decode("urn:x-ogc:def:crs:EPSG:26713"), schema.getGeometryDescriptor().getType().getCoordinateReferenceSystem()); assertEquals(Integer.class, schema.getDescriptor("cat").getType().getBinding()); } }
@Override public List<ImportTask> list(ImportData data, Catalog catalog, ProgressMonitor monitor) throws IOException { File file = getFileFromData(data); SimpleFeatureType featureType = getSchema(file); CatalogFactory factory = catalog.getFactory(); CatalogBuilder cb = new CatalogBuilder(catalog);
@Override public boolean canRead(ImportData data) throws IOException { File file = getFileFromData(data); return file.canRead() && "gml".equalsIgnoreCase(FilenameUtils.getExtension(file.getName())); }
updateSimpleTypeGuess(name, sf.getAttribute(name), guessedTypes);
@Test public void testParsePoiGML3() throws Exception { File file = new File("./src/test/resources/org/geoserver/importer/test-data/gml/poi.gml3.gml"); SimpleFeatureType schema = gmlFileFormat.getSchema(file); assertEquals(Point.class, schema.getGeometryDescriptor().getType().getBinding()); assertEquals( CRS.decode("urn:x-ogc:def:crs:EPSG:4326", false), schema.getGeometryDescriptor().getType().getCoordinateReferenceSystem()); assertEquals(String.class, schema.getDescriptor("NAME").getType().getBinding()); assertEquals(Integer.class, schema.getDescriptor("intAttribute").getType().getBinding()); assertEquals(Double.class, schema.getDescriptor("floatAttribute").getType().getBinding()); }
@Test public void testParsePoiGML2() throws Exception { File file = new File("./src/test/resources/org/geoserver/importer/test-data/gml/poi.gml2.gml"); SimpleFeatureType schema = gmlFileFormat.getSchema(file); assertEquals(Point.class, schema.getGeometryDescriptor().getType().getBinding()); assertEquals( CRS.decode("EPSG:4326", true), schema.getGeometryDescriptor().getType().getCoordinateReferenceSystem()); assertEquals(String.class, schema.getDescriptor("NAME").getType().getBinding()); assertEquals(Integer.class, schema.getDescriptor("intAttribute").getType().getBinding()); assertEquals(Double.class, schema.getDescriptor("floatAttribute").getType().getBinding()); }
@Test public void testParseStreamsGML2() throws Exception { File file = new File( "./src/test/resources/org/geoserver/importer/test-data/gml/streams.gml2.gml"); SimpleFeatureType schema = gmlFileFormat.getSchema(file); assertEquals(MultiLineString.class, schema.getGeometryDescriptor().getType().getBinding()); assertEquals( CRS.decode("EPSG:26713"), schema.getGeometryDescriptor().getType().getCoordinateReferenceSystem()); assertEquals(String.class, schema.getDescriptor("cat").getType().getBinding()); assertEquals(Date.class, schema.getDescriptor("acquired").getType().getBinding()); assertEquals(Date.class, schema.getDescriptor("acquiredFull").getType().getBinding()); }