You are warned that GML does not determine the file format. It provides an abstract starting point for defining your own xml schema. We use a scheme to sort the xml elements to map to that Java class (so dates are displayed as Date, geometry as JTS Geometry, etc.).
This causes a lot of grief among people who were provided with only a GML file; that I recently added a utility class (called GML) to GeoTools that assumes that any undefined element is a string.
Here is an example from test cases:
URL url = TestData.getResource(this, "states.gml"); InputStream in = url.openStream(); GML gml = new GML(Version.GML3); SimpleFeatureCollection featureCollection = gml.decodeFeatureCollection(in);
You can take the resulting featureCollection and use the JMapPane class, as shown in quickstart GeoTools ::
MapContext map = new DefaultMapContext(); map.setTitle("Quickstart"); map.addLayer(featureCollection, null);
source share