Hi, I have a simple GML3 Application schema which I use to encode a featurecollection to a gml document. However I do not succeed in getting duplicate gml:id's in geometry elements to be replaced by xlink:href attributes. Even worse: duplicate id's are accepted while I thought that the XSDIdRegistry would take care of that. I am using geotools 2.6.3 Any suggestions? Regards, Rob van Swol Here are some relevant parts of my code: /*Create FeatureType */ SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.setName("Effect"); builder.setNamespaceURI(NS_IMDT); builder.setCRS(CRS.decode("EPSG:28992")); // <- Coordinate reference system // add attributes in order builder.add("geometrie", Geometry.class); builder.length(15).add("id", String.class); builder.add("title", String.class); builder.add("xeffecten", String.class); builder.add("xmaatregelen", String.class); builder.setDefaultGeometry( "geometrie" ); // build the type final SimpleFeatureType effectType = builder.buildFeatureType(); /*Create the features and add to collection*/ FeatureCollection<SimpleFeatureType, SimpleFeature> collection = FeatureCollections.newCollection("S1"); SimpleFeatureBuilder fb = new SimpleFeatureBuilder(effectType) String wkt = "POLYGON((127200 493100,127200 495100,130000 495100,130000 493100,127200 493100))"; Geometry geometry = (new WKTReader2()).read(wkt); HashMap userData = new HashMap(); userData.put("gml:id", "piet"); geometry.setUserData(userData); fb.add(geometry); fb.add(id); fb.add(name); fb.add(""); fb.add(xmaatregelen); feature = fb.buildFeature(id); collection.add(feature); /* Create GML from this collection */ ApplicationSchemaConfiguration config = new ApplicationSchemaConfiguration(namespace, schemaLocation); org.geotools.xml.Encoder encoder = new org.geotools.xml.Encoder(config); encoder.setIndenting(true); encoder.setSchemaLocation(namespace, schemaLocation); encoder.setSchemaLocation("http://www.opengis.net/gml", "http://schemas.opengis.net/gml/3.1.1/base/gml.xsd"); encoder.encode(collection, GML.FeatureCollection, System.out); This is my schema: IMDTool.xsd <?xml version="1.0" encoding="windows-1252"?><schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" xmlns:imdt="http://geomatics.nlr.nl/IMDTool" elementFormDefault="qualified" targetNamespace="http://geomatics.nlr.nl/IMDTool" version="1.0"> <import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd"/> <!--XML Schema document created by ShapeChange--> <element name="Effect" substitutionGroup="gml:_Feature" type="imdt:EffectType"/> <complexType name="EffectType"> <complexContent> <extension base="gml:AbstractFeatureType"> <sequence> <element name="id" type="string"/> <element name="title" type="string"/> <element name="xeffecten" type="string"/> <element name="xmaatregelen" type="string"/> <element name="geometrie" type="gml:SurfacePropertyType"/> </sequence> </extension> </complexContent> </complexType> <complexType name="EffectPropertyType"> <sequence minOccurs="0"> <element ref="imdt:Effect"/> </sequence> <attributeGroup ref="gml:AssociationAttributeGroup"/> </complexType> </schema> Producing the following output: <?xml version="1.0" encoding="UTF-8"?> <gml:FeatureCollection xsi:schemaLocation="http://geomatics.nlr.nl/IMDTool IMDTool.xsd http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/base/gml.xsd" xmlns:imdt="http://geomatics.nlr.nl/IMDTool" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <gml:featureMembers> <imdt:Effect gml:id="E1"> <gml:boundedBy> <gml:Envelope srsName="http://www.opengis.net/gml/srs/epsg.xml#28992"> <gml:lowerCorner>127200.0 493100.0</gml:lowerCorner> <gml:upperCorner>130000.0 495100.0</gml:upperCorner> </gml:Envelope> </gml:boundedBy> <imdt:id>E1</imdt:id> <imdt:title>effect1</imdt:title> <imdt:xeffecten></imdt:xeffecten> <imdt:xmaatregelen>M1</imdt:xmaatregelen> <imdt:geometrie> <gml:Polygon gml:id="piet"> <gml:exterior> <gml:LinearRing> <gml:posList>127200.0 493100.0 127200.0 495100.0 130000.0 495100.0 130000.0 493100.0 127200.0 493100.0</gml:posList> </gml:LinearRing> </gml:exterior> </gml:Polygon> </imdt:geometrie> </imdt:Effect> <imdt:Effect gml:id="E2"> <gml:boundedBy> <gml:Envelope srsName="http://www.opengis.net/gml/srs/epsg.xml#28992"> <gml:lowerCorner>184700.0 515900.0</gml:lowerCorner> <gml:upperCorner>197900.0 525500.0</gml:upperCorner> </gml:Envelope> </gml:boundedBy> <imdt:id>E2</imdt:id> <imdt:title>Eerste effect</imdt:title> <imdt:xeffecten></imdt:xeffecten> <imdt:xmaatregelen>M1</imdt:xmaatregelen> <imdt:geometrie> <gml:Polygon gml:id="piet"> <gml:exterior> <gml:LinearRing> <gml:posList>127200.0 493100.0 127200.0 495100.0 130000.0 495100.0 130000.0 493100.0 127200.0 493100.0</gml:posList> </gml:LinearRing> </gml:exterior> </gml:Polygon> </imdt:geometrie> </imdt:Effect> </gml:featureMembers> </gml:FeatureCollection> --
The NLR disclaimer is valid for NLR e-mail messages. |
------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev
_______________________________________________ Geotools-devel mailing list Geotools-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-devel