Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GML_322_support] add GML 3.2.2 support #1104

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
package org.deegree.feature.types;

import static org.deegree.gml.GMLVersion.GML_32;
import static org.deegree.gml.GMLVersion.GML_322;

import java.util.HashSet;
import java.util.Set;
Expand Down Expand Up @@ -119,7 +120,7 @@ public class AppSchemaGeometryHierarchy {
}

private QName getAbstractElementName( String localPart, GMLVersion version ) {
if ( version == GML_32 ) {
if ( version == GML_32 || version == GML_322 ) {
return new QName( version.getNamespace(), "Abstract" + localPart );
}
return new QName( version.getNamespace(), "_" + localPart );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import static org.deegree.gml.GMLVersion.GML_30;
import static org.deegree.gml.GMLVersion.GML_31;
import static org.deegree.gml.GMLVersion.GML_32;
import static org.deegree.gml.GMLVersion.GML_322;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -64,11 +65,13 @@ public class ParameterType {
public static final ParameterType GEOMETRY = new ParameterType( new QName( GMLNS, "_Geometry", "gml" ),
new QName( GMLNS, "_Geometry", "gml" ),
new QName( GMLNS, "_Geometry", "gml" ),
new QName( GML3_2_NS, "AbstractGeometry", "gml32" ),
new QName( GML3_2_NS, "AbstractGeometry", "gml32" ) );

public static final ParameterType POINT = new ParameterType( new QName( GMLNS, "Point", "gml" ),
new QName( GMLNS, "Point", "gml" ),
new QName( GMLNS, "Point", "gml" ),
new QName( GML3_2_NS, "Point", "gml32" ),
new QName( GML3_2_NS, "Point", "gml32" ) );

public static final ParameterType STRING = new ParameterType( new QName( XSNS, "string", "xsd" ) );
Expand All @@ -88,13 +91,15 @@ public ParameterType( QName name ) {
versionToName.put( GML_30, name );
versionToName.put( GML_31, name );
versionToName.put( GML_32, name );
versionToName.put( GML_322, name );
}

public ParameterType( QName gml2Name, QName gml30Name, QName gml31Name, QName gml32Name ) {
public ParameterType( QName gml2Name, QName gml30Name, QName gml31Name, QName gml32Name, QName gml322Name ) {
versionToName.put( GML_2, gml2Name );
versionToName.put( GML_30, gml30Name );
versionToName.put( GML_31, gml31Name );
versionToName.put( GML_32, gml32Name );
versionToName.put( GML_322, gml322Name );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,8 @@ public GMLGeometryReader getGeometryReader() {
}
case GML_30:
case GML_31:
case GML_32: {
case GML_32:
case GML_322: {
geometryReader = new GML3GeometryReader( this );
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import static org.deegree.feature.property.ExtraProps.EXTRA_PROP_NS_GEOMETRY;
import static org.deegree.feature.property.ExtraProps.EXTRA_PROP_NS_STRING;
import static org.deegree.gml.GMLVersion.GML_32;
import static org.deegree.gml.GMLVersion.GML_322;

import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -134,14 +135,29 @@ public class GMLStreamWriter {
this.xmlStream = xmlStream;
referenceExportStrategy = new DefaultGmlXlinkStrategy( "#{}", new GmlXlinkOptions() );
prefixToNs.put( "ogc", OGCNS );
prefixToNs.put( "gml", version != GML_32 ? GMLNS : GML3_2_NS );
prefixToNs.put( "gml", !isVersionOfGML32( version ) ? GMLNS : GML3_2_NS );
prefixToNs.put( "xlink", XLNNS );
prefixToNs.put( "xsi", XSINS );
prefixToNs.put( "dxtra", EXTRA_PROP_NS );
prefixToNs.put( "dxtra-string", EXTRA_PROP_NS_STRING );
prefixToNs.put( "dxtra-geometry", EXTRA_PROP_NS_GEOMETRY );
}

/**
* Returns if a version is of GML 3.2.
*
* @param version
* GML version of the output, must not be <code>null</code>
*
* @return <code>true</code>, if version is 3.2.1 or 3.2.2, <code>false</code> otherwise
*/
private boolean isVersionOfGML32( GMLVersion version ) {
if ( version == GML_32 || version == GML_322 ){
return true;
}
return false;
}

/**
* Returns the GML version of the generated output.
*
Expand Down Expand Up @@ -413,7 +429,8 @@ public GMLGeometryWriter getGeometryWriter() {
}
case GML_30:
case GML_31:
case GML_32: {
case GML_32:
case GML_322: {
geometryWriter = new GML3GeometryWriter( this );
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ public enum GMLVersion {
GML_30( GMLNS, "3.0", "3.0.1" ),
/** GML 3.1 versions (either 3.1.0 or 3.1.1) */
GML_31( GMLNS, "3.1", "3.1.1" ),
/** GML 3.2 versions (3.2.1) */
GML_32( GML3_2_NS, "3.2", "3.2.1" );
/** GML 3.2.1 versions (3.2.1) */
GML_32( GML3_2_NS, "3.2", "3.2.1" ),
/** GML 3.2.2 versions (3.2.2) */
GML_322( GML3_2_NS, "3.2", "3.2.2" );

private final String ns;

Expand Down Expand Up @@ -141,6 +143,8 @@ public static GMLVersion fromMimeType( String mimeType, GMLVersion defaultVersio
result = GML_31;
} else if ( v.compareTo( new Version( 3, 2, 1 ) ) <= 0 ) {
result = GML_32;
} else if ( v.compareTo( new Version( 3, 2, 2 ) ) <= 0 ) {
result = GML_322;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@
import static org.deegree.commons.xml.stax.XMLStreamUtils.nextElement;
import static org.deegree.commons.xml.stax.XMLStreamUtils.require;
import static org.deegree.commons.xml.stax.XMLStreamUtils.skipElement;
import static org.deegree.gml.GMLVersion.GML_2;
import static org.deegree.gml.GMLVersion.GML_30;
import static org.deegree.gml.GMLVersion.GML_31;
import static org.deegree.gml.GMLVersion.GML_32;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -204,7 +202,7 @@ private boolean isGmlIdRequired() {
if ( gmlStreamReader.getLaxMode() ) {
return false;
}
return version != GML_2 && version != GML_30 || version != GML_31;
return version == GML_32;
}

private void checkValidNcName( final String gmlId ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import static org.deegree.geometry.Geometry.GeometryType.ENVELOPE;
import static org.deegree.gml.GMLVersion.GML_30;
import static org.deegree.gml.GMLVersion.GML_32;
import static org.deegree.gml.GMLVersion.GML_322;

import java.util.List;
import java.util.UUID;
Expand Down Expand Up @@ -119,6 +120,7 @@
import org.deegree.geometry.refs.GeometryReference;
import org.deegree.geometry.standard.curvesegments.AffinePlacement;
import org.deegree.gml.GMLStreamWriter;
import org.deegree.gml.GMLVersion;
import org.deegree.gml.commons.AbstractGMLObjectWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -261,7 +263,7 @@ public void exportMultiGeometry( MultiGeometry<? extends Geometry> geometry )
break;
}
case MULTI_LINE_STRING: {
if ( version == GML_32 ) {
if ( isGML32version( version ) ) {
// GML 3.2 does not define MultiLineString anymore -> export as MultiCurve
MultiCurve<Curve> multiCurve = (MultiCurve<Curve>) geometry;
startGeometry( "MultiCurve", geometry );
Expand Down Expand Up @@ -308,7 +310,7 @@ public void exportMultiGeometry( MultiGeometry<? extends Geometry> geometry )
writer.writeEndElement(); // MultiPoint
break;
case MULTI_POLYGON:
if ( version == GML_32 ) {
if ( isGML32version( version ) ) {
// GML 3.2 does not define MultiPolygon anymore -> export as MultiSurface
MultiSurface<Surface> multiSurface = (MultiSurface<Surface>) geometry;
startGeometry( "MultiSurface", geometry );
Expand Down Expand Up @@ -743,7 +745,7 @@ public void exportRing( Ring ring )

switch ( ring.getRingType() ) {
case Ring:
if ( GML_32 != version ) {
if ( !isGML32version( version ) ) {
startGeometry( "Ring", ring );
} else {
// in GML 3.2, a Ring is not a Geometry object
Expand All @@ -760,7 +762,7 @@ public void exportRing( Ring ring )
case LinearRing:
LinearRing linearRing = (LinearRing) ring;

if ( GML_32 != version ) {
if ( !isGML32version( version ) ) {
startGeometry( "LinearRing", linearRing );
} else {
// in GML 3.2, a LinearRing is not a Geometry object
Expand All @@ -774,6 +776,13 @@ public void exportRing( Ring ring )
}
}

private boolean isGML32version( GMLVersion version ) {
if ( version == GML_32 || version == GML_322 ) {
return true;
}
return false;
}

/**
* Exporting a composite curve via the XMLStreamWriter given when the class was constructed
*
Expand Down Expand Up @@ -1561,7 +1570,7 @@ private void startGeometry( String localName, Geometry geometry )
referenceExportStrategy.addExportedId( geometry.getId() );
writeAttributeWithNS( gmlNs, "id", geometry.getId() );
} else if ( version == GML_32 && geometry.getId() == null ) {
// in GML 3.2, a gml:id is required for every geometry
// Only in GML 3.2.1, a gml:id is required for every geometry
writeAttributeWithNS( gmlNs, "id", "GEOMETRY_" + generateNewId() );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public GMLStdProps read( XMLStreamReader xmlStream )
props = readGML31( xmlStream );
break;
case GML_32:
case GML_322:
props = readGML32( xmlStream );
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public void write( GMLStdProps props )
writeGML3( props );
break;
case GML_32:
case GML_322:
writeGML32( props );
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ public GMLAppSchemaWriter( GMLVersion version, String targetNamespace, Map<Strin
}
break;
case GML_32:
case GML_322:
gmlNsURI = GML3_2_NS;
abstractGMLFeatureElement = "gml:AbstractFeature";
featurePropertyType = "gml:FeaturePropertyType";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ private void init( GMLVersion version ) {
abstractFeatureElementTypeDecl = getTypeDef( "AbstractFeatureType", GML_PRE_32_NS );
break;
}
case GML_32: {
case GML_32:
case GML_322: {
abstractObjectElementDecl = getElementDecl( "AbstractObject", GML_32_NS );
abstractGmlElementDecl = getElementDecl( "AbstractGML", GML_32_NS );
abstractFeatureElementDecl = getElementDecl( "AbstractFeature", GML_32_NS );
Expand Down Expand Up @@ -295,6 +296,7 @@ private void init( GMLVersion version ) {
break;
}
case GML_32:
case GML_322: {
List<XSElementDeclaration> featureDecls = getFeatureElementDeclarations( null, false );
fcDecls = new ArrayList<XSElementDeclaration>();
for ( XSElementDeclaration featureDecl : featureDecls ) {
Expand All @@ -304,6 +306,7 @@ private void init( GMLVersion version ) {
}
break;
}
}

for ( XSElementDeclaration elemDecl : ftDecls ) {
QName name = new QName( elemDecl.getNamespace(), elemDecl.getName() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@

import static junit.framework.Assert.assertEquals;
import static org.deegree.gml.GMLVersion.fromMimeType;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;

import org.junit.Test;

Expand Down Expand Up @@ -105,17 +108,32 @@ public void gml3_2_0() {
}

@Test
public void gml3_2_1() {
public void gml3_2() {
assertEquals( GMLVersion.GML_32, fromMimeType( "text/xml; subtype=gml/3.2.1", null ) );
}

@Test
public void gml3_2_2() {
assertEquals( GMLVersion.GML_322, fromMimeType( "text/xml; subtype=gml/3.2.2", null ) );
}

@Test
public void subtypeGML3_2_1shouldNotMatchGMLVersion322() {
assertThat( GMLVersion.GML_322, is( not( fromMimeType( "text/xml; subtype=gml/3.2.1", null ) ) ) );
}

@Test
public void subtypeGML3_2_2shouldNotMatchGMLVersion32() {
assertThat( GMLVersion.GML_32, is( not( fromMimeType( "text/xml; subtype=gml/3.2.2", null ) ) ) );
}

@Test
public void noGML() {
assertEquals( null, fromMimeType( "text/xml", null ) );
}

@Test
public void multipleSubtypes() {
public void multipleSubtypesGML32() {
assertEquals( GMLVersion.GML_32, fromMimeType( "text/xml; subtype=gml/3.2; subtype=gml/3.2.1", null ) );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@

import org.deegree.gml.GMLInputFactory;
import org.deegree.gml.GMLStreamReader;
import org.deegree.time.gml.reader.GmlTimePositionTypeReader;
import org.deegree.time.position.TimePosition;
import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ public void serialize( FeatureInfoParams params, FeatureInfoContext context )
if ( format.endsWith( "3.2" ) || format.endsWith( "3.2.1" ) ) {
gmlVersion = GMLVersion.GML_32;
}
if ( format.endsWith( "3.2.2" ) ) {
gmlVersion = GMLVersion.GML_322;
}

GMLStreamWriter gmlWriter = GMLOutputFactory.createGMLStreamWriter( gmlVersion, xmlWriter );
gmlWriter.setOutputCrs( params.getCrs() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import static org.deegree.commons.xml.CommonNamespaces.XLNNS;
import static org.deegree.commons.xml.XMLAdapter.writeElement;
import static org.deegree.commons.xml.stax.XMLStreamUtils.skipElement;
import static org.deegree.feature.Features.findFeaturesAndGeometries;
import static org.deegree.gml.GMLInputFactory.createGMLStreamReader;
import static org.deegree.gml.GMLVersion.GML_32;
import static org.deegree.protocol.wfs.WFSConstants.VERSION_100;
Expand All @@ -68,11 +67,9 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
Expand Down Expand Up @@ -114,8 +111,6 @@
import org.deegree.filter.IdFilter;
import org.deegree.filter.OperatorFilter;
import org.deegree.filter.expression.ValueReference;
import org.deegree.geometry.Envelope;
import org.deegree.geometry.Geometry;
import org.deegree.geometry.GeometryFactory;
import org.deegree.geometry.SimpleGeometryFactory;
import org.deegree.geometry.validation.CoordinateValidityInspector;
Expand All @@ -124,7 +119,6 @@
import org.deegree.gml.GMLVersion;
import org.deegree.gml.feature.GMLFeatureReader;
import org.deegree.gml.reference.FeatureReference;
import org.deegree.gml.reference.matcher.ReferencePatternMatcher;
import org.deegree.protocol.wfs.transaction.ReleaseAction;
import org.deegree.protocol.wfs.transaction.Transaction;
import org.deegree.protocol.wfs.transaction.TransactionAction;
Expand Down Expand Up @@ -911,6 +905,8 @@ private GMLVersion determineFormat( Version requestVersion, String format ) {
gmlVersion = GMLVersion.GML_31;
} else if ( "text/xml; subtype=gml/3.2.1".equals( format ) ) {
gmlVersion = GMLVersion.GML_32;
} else if ( "text/xml; subtype=gml/3.2.2".equals( format ) ) {
gmlVersion = GMLVersion.GML_322;
}
}
return gmlVersion;
Expand Down
Loading