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

Enhance SLD/SE functions #1204

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4074843
#7692 (PR#83) - added deegree-core/deegree-core-style-ext
stephanr Sep 1, 2021
a6d2e14
#7703 (PR#83) - enhanced documentation
stephanr Oct 4, 2021
e938667
#7692 (PR#199) - removed xalan
lgoltz Oct 5, 2021
9dc06b6
Merge branch 'deegree:master' into enhancement/migrations-styling-enh…
lgoltz Dec 15, 2021
5d3dc24
Merge remote-tracking branch 'origin/upgradeJts-1046-7816' into enhan…
lgoltz Dec 15, 2021
6d5aa05
Merge branch 'enhancement/migrations-styling-enhacments-dee-83-7692' …
lgoltz Dec 15, 2021
27fd4d8
#7960 - fixed jts imports, fixed versions and groupId, skipped failin…
lgoltz Dec 15, 2021
fac57a9
Merge remote-tracking branch 'origin/master' into enhancement/migrati…
dstenger Dec 22, 2021
2ce8aef
updated deegree version in deegree-core/deegree-core-style-ext/pom.xm…
lgoltz Jan 3, 2022
b402da9
Merge remote-tracking branch 'deegree/master' into enhancement/migrat…
lgoltz Jan 10, 2022
2eef171
update to 3.4.24-SNAPSHOT
lgoltz Jan 10, 2022
500d3cb
Merge remote-tracking branch 'deegree/master' into enhancement/migrat…
lgoltz Feb 14, 2022
2f3ea22
update to deegree 3.4.25-SNAPSHOT
lgoltz Feb 14, 2022
312a729
Merge branch 'deegree:master' into enhancement/migrations-styling-enh…
lgoltz Feb 23, 2022
ca2b3c8
update to deegree 3.4.26-SNAPSHOT
lgoltz Feb 23, 2022
b148b7d
Merge remote-tracking branch 'deegree/master' into enhancement/migrat…
lgoltz Mar 23, 2022
0a0187e
update to 3.4.28-SNAPSHOT
lgoltz Mar 23, 2022
7599c38
Merge branch 'deegree:master' into enhancement/migrations-styling-enh…
lgoltz Apr 28, 2022
b4b50c4
update to 3.4.30-SNAPSHOT
lgoltz Apr 28, 2022
a19395c
Merge remote-tracking branch 'deegree/main' into enhancement/migratio…
lgoltz Jun 16, 2022
f88b815
upgrade to 3.5.0-SNAPSHOT
lgoltz Jun 16, 2022
c8865c2
Merge remote-tracking branch 'deegree/main' into enhancement/migratio…
lgoltz Oct 12, 2022
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//$HeadURL$
/*----------------------------------------------------------------------------
This file is part of deegree, http://deegree.org/
Copyright (C) 2001-2009 by:
Expand Down Expand Up @@ -64,14 +63,17 @@
import org.deegree.geometry.points.Points;
import org.deegree.geometry.precision.PrecisionModel;
import org.deegree.geometry.primitive.Curve;
import org.deegree.geometry.primitive.Curve.CurveType;
import org.deegree.geometry.primitive.GeometricPrimitive;
import org.deegree.geometry.primitive.LineString;
import org.deegree.geometry.primitive.LinearRing;
import org.deegree.geometry.primitive.Point;
import org.deegree.geometry.primitive.Polygon;
import org.deegree.geometry.primitive.Ring;
import org.deegree.geometry.primitive.Ring.RingType;
import org.deegree.geometry.primitive.Solid;
import org.deegree.geometry.primitive.Surface;
import org.deegree.geometry.primitive.Surface.SurfaceType;
import org.deegree.geometry.primitive.Tin;
import org.deegree.geometry.primitive.patches.GriddedSurfacePatch;
import org.deegree.geometry.primitive.patches.PolygonPatch;
Expand All @@ -89,6 +91,7 @@
import org.deegree.geometry.primitive.segments.Clothoid;
import org.deegree.geometry.primitive.segments.CubicSpline;
import org.deegree.geometry.primitive.segments.CurveSegment;
import org.deegree.geometry.primitive.segments.CurveSegment.CurveSegmentType;
import org.deegree.geometry.primitive.segments.Geodesic;
import org.deegree.geometry.primitive.segments.GeodesicString;
import org.deegree.geometry.primitive.segments.LineStringSegment;
Expand All @@ -103,9 +106,7 @@
*
* @author <a href="mailto:thomas@lat-lon.de">Steffen Thomas</a>
* @author <a href="mailto:schneider@lat-lon.de">Markus Schneider</a>
* @author last edited by: $Author$
*
* @version $Revision$, $Date$
* @author <a href="mailto:reichhelm@grit.de">Stephan Reichhelm</a>
*/
public class WKTWriter {

Expand All @@ -123,9 +124,6 @@ public class WKTWriter {
* The flag is used to specify which geometric operations the database is capable of
*
* @author <a href="mailto:thomas@lat-lon.de">Steffen Thomas</a>
* @author last edited by: $Author$
*
* @version $Revision$, $Date$
*/
public enum WKTFlag {
/** Export can use ENVELOPE */
Expand Down Expand Up @@ -210,6 +208,7 @@ public void setLinearizedControlPoints( int linearizedControlPoints ) {
* that is used
* @throws IOException
*/
@SuppressWarnings("unchecked")
public void writeGeometry( Geometry geometry, Writer writer )
throws IOException {

Expand Down Expand Up @@ -465,14 +464,41 @@ private void writePolygonPatch( String id, ICRS crs, PrecisionModel pm, PolygonP
*/
public void writePolygon( Polygon geometry, Writer writer )
throws IOException {

writer.append( "POLYGON " );
if ( flags.contains( WKTFlag.USE_SQL_MM ) ) {
if ( isCompoundPolyogn( geometry ) ) {
writeCurvePolygon( geometry, writer );
return;
} else {
writer.append( "POLYGON " );
}
} else {
writer.append( "POLYGON " );
}
if ( flags.contains( WKTFlag.USE_DKT ) ) {
appendObjectProps( writer, geometry );
}
writePolygonWithoutPrefix( geometry, writer );
}

private void writeCurvePolygon( Polygon geometry, Writer writer )
throws IOException {
writer.append( "CURVEPOLYGON " );
writer.append( "(" );
writeCurvePolygonWithoutPrefix( geometry, writer );
writer.append( ')' );
}

private void writeCurvePolygonWithoutPrefix( Polygon geometry, Writer writer )
throws IOException {
writeCurveGeometry( geometry.getExteriorRing(), writer );

for ( Ring ring : geometry.getInteriorRings() ) {
writer.append( ',' );
writeCurveGeometry( ring, writer );

}
}

/**
* Writes the POLYGON without the 'POLYGON()'-specific envelope. <br/>
* It writes just the POLYGON-coordinates.
Expand Down Expand Up @@ -573,8 +599,20 @@ public void writeCompositeCurve( CompositeCurve geometry, Writer writer )
} else if ( flags.contains( WKTFlag.USE_SQL_MM ) ) {
writer.append( "COMPOUNDCURVE " );
writer.append( '(' );
// TODO implementation here; no values commited

int counter = 0;
for ( Curve c : geometry ) {
counter++;
if ( c.getCurveType() == CurveType.LineString ) {
writer.append( '(' );
writeLineStringWithoutPrefix( (LineString) c, writer );
writer.append( ')' );
} else {
writeCurve( c, writer );
}
if ( counter != geometry.size() ) {
writer.append( ',' );
}
}
} else {

List<Curve> l = geometry.subList( 0, geometry.size() );
Expand Down Expand Up @@ -608,12 +646,16 @@ public void writeCurveGeometry( Curve geometry, Writer writer )
writeCurveSegments( geometry, writer );
writer.append( ')' );
} else if ( flags.contains( WKTFlag.USE_SQL_MM ) ) {

// s.append( "COMPOUNDCURVE(" );
throw new UnsupportedOperationException( "Handling curves within 'SQL-MM Part 3' is not implemented yet." );

int segments = geometry.getCurveSegments().size();
if ( segments > 1 ) {
writer.write( "COMPOUNDCURVE (" );
}
writeCurveSegments( geometry, writer );
if ( segments > 1 ) {
writer.write( ')' );
}
} else {
CurveLinearizer cl = new CurveLinearizer( new GeometryFactory() );
CurveLinearizer cl = linearizer != null ? linearizer : new CurveLinearizer( new GeometryFactory() );
LinearizationCriterion crit = new NumPointsCriterion( linearizedControlPoints );
Curve c = cl.linearize( geometry, crit );

Expand All @@ -635,7 +677,15 @@ private void writeCurveGeometryWithoutPrefix( Curve geometry, Writer writer )
throws IOException {

if ( flags.contains( WKTFlag.USE_SQL_MM ) ) {
throw new UnsupportedOperationException( "Handling curves within 'SQL-MM Part 3' is not implemented yet." );
int segments = geometry.getCurveSegments().size();
if ( segments > 1 ) {
writer.write( "COMPOUNDCURVE (" );
}
writeCurveSegments( geometry, writer );
if ( segments > 1 ) {
writer.write( ')' );
}
return;
}
CurveLinearizer cl = new CurveLinearizer( new GeometryFactory() );
LinearizationCriterion crit = new NumPointsCriterion( linearizedControlPoints );
Expand All @@ -660,7 +710,6 @@ private void writeCurveSegments( Curve geometry, Writer writer )
List<CurveSegment> g = geometry.getCurveSegments();
int counter = 0;
for ( CurveSegment c : g ) {

switch ( c.getSegmentType() ) {
case ARC:
counter++;
Expand Down Expand Up @@ -727,9 +776,7 @@ private void writeCurveSegments( Curve geometry, Writer writer )
if ( counter != g.size() ) {
writer.append( ',' );
}

}

}

/**
Expand Down Expand Up @@ -852,7 +899,11 @@ private void writeArcStringByBulge( ArcStringByBulge curve, Writer writer ) {
*/
private void writeArcString( ArcString curve, Writer writer )
throws IOException {
writer.append( "ARCSTRING " );
if ( flags.contains( WKTFlag.USE_SQL_MM ) ) {
writer.append( "CIRCULARSTRING " );
} else {
writer.append( "ARCSTRING " );
}
// if(flags.contains( WKTFlag.USE_DKT )){
// appendObjectProps( writer, (Geometry) arcString );
// }
Expand Down Expand Up @@ -897,7 +948,11 @@ private void writeArcByBulge( ArcByBulge curve, Writer writer ) {
*/
private void writeLineStringSegment( LineStringSegment curve, Writer writer )
throws IOException {
writer.append( "LINESTRINGSEGMENT " );
if ( flags.contains( WKTFlag.USE_SQL_MM ) ) {
// write nothing
} else {
writer.append( "LINESTRINGSEGMENT " );
}
// if(flags.contains( WKTFlag.USE_DKT )){
// appendObjectProps( writer, (Geometry) createLineStringSegment );
// }
Expand All @@ -922,7 +977,12 @@ private void writeLineStringSegment( LineStringSegment curve, Writer writer )
*/
private void writeArc( Arc curve, Writer writer )
throws IOException {
writer.append( "ARC " );
if ( flags.contains( WKTFlag.USE_SQL_MM ) ) {
writer.append( "CIRCULARSTRING " );
} else {
writer.append( "ARC " );
}

// if(flags.contains( WKTFlag.USE_DKT )){
// appendObjectProps( writer, (Geometry) createArc );
// }
Expand Down Expand Up @@ -1046,6 +1106,7 @@ public void writeLinearRing( LinearRing geometry, Writer writer )
* @param writer
* @throws IOException
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public void writeMultiGeometry( MultiGeometry<? extends Geometry> geometry, Writer writer )
throws IOException {

Expand Down Expand Up @@ -1096,7 +1157,31 @@ public void writeMultiSolid( MultiSolid geometry, Writer writer ) {
*/
public void writeMultiSurface( MultiSurface<Surface> geometry, Writer writer )
throws IOException {
writer.append( "MULTIPOLYGON " );
if ( flags.contains( WKTFlag.USE_SQL_MM ) ) {
writer.append( "MULTISURFACE " );
writer.write( '(' );
int counter = 0;
for ( Surface surface : geometry ) {
counter++;
if ( surface.getSurfaceType() == SurfaceType.Polygon ) {
if ( isCompoundPolyogn( (Polygon) surface ) ) {
writeCurvePolygon( (Polygon) surface, writer );
} else {
writer.write( '(' );
writeCurvePolygonWithoutPrefix( (Polygon) surface, writer );
writer.write( ')' );
}
} else {
writeSurface( surface, writer );
}
if ( counter < geometry.size() )
writer.write( ',' );
}
writer.write( ')' );
return;
} else {
writer.append( "MULTIPOLYGON " );
}
if ( flags.contains( WKTFlag.USE_DKT ) ) {
appendObjectProps( writer, geometry );
}
Expand All @@ -1121,7 +1206,11 @@ public void writeMultiSurface( MultiSurface<Surface> geometry, Writer writer )
public void writeMultiCurve( MultiCurve<Curve> geometry, Writer writer )
throws IOException {

writer.append( "MULTILINESTRING " );
if ( flags.contains( WKTFlag.USE_SQL_MM ) ) {
writer.append( "MULTICURVE " );
} else {
writer.append( "MULTILINESTRING " );
}
if ( flags.contains( WKTFlag.USE_DKT ) ) {
appendObjectProps( writer, geometry );
}
Expand Down Expand Up @@ -1315,6 +1404,7 @@ public void writeEnvelope( Envelope envelope, Writer writer )
* @return a wkt String representation of the given geometry, of the emtpy string if the geometry is
* <code>null</code>
*/
@SuppressWarnings("unchecked")
public static String write( Geometry geom ) {
if ( geom == null ) {
return "";
Expand Down Expand Up @@ -1345,19 +1435,19 @@ public static String write( Geometry geom ) {
* if the writer is <code>null</code>
*/
public static void write( Geometry geom, Writer writer )
throws IOException, NullPointerException {
throws IOException,
NullPointerException {
if ( geom == null ) {
return;
}
if ( writer == null ) {
throw new NullPointerException( "The writer may not be null." );
}
Set<WKTFlag> flags = new HashSet<WKTFlag>();
int dim =geom.getCoordinateDimension();
if (dim == 3){
int dim = geom.getCoordinateDimension();
if ( dim == 3 ) {
flags.add( WKTWriter.WKTFlag.USE_3D );
}
else{
} else {
flags = null;
}
WKTWriter wktW = new WKTWriter( flags, null );
Expand Down Expand Up @@ -1387,4 +1477,67 @@ private void appendObjectProps( Writer writer, Geometry geom )
writer.append( '\'' );
writer.append( ']' );
}

/**
* Test if Polygon is made from compound rings
*
* @return true if the polygon is constructed from non-linear rings, rings which are non-linear or rings with
* contains more than one segment
*/
private boolean isCompoundPolyogn( Polygon geometry ) {
if ( isCompoundRing( geometry.getExteriorRing() ) ) {
return true;
}
for ( Ring ring : geometry.getInteriorRings() ) {
if ( isCompoundRing( ring ) ) {
return true;
}
}
return false;
}

/**
* Test if Ring is compound (non-linear or made from more than one segment)
*
* @return true if the ring is non-linear or the ring is made from more than one segment
*/
private boolean isCompoundRing( Ring geometry ) {
if ( geometry.getRingType() == RingType.LinearRing ) {
return false;
} else {
if ( geometry.getMembers().size() > 1 )
return true;

for ( Curve c : geometry.getMembers() ) {
if ( isCompoundCurve( c ) ) {
return true;
}
}
}
return false;
}

/**
* Test if Curve is compound (non-linear or made from more than one segment)
*
* @return true if the curve is non-linear or the curve is made from more than one segment
*/
private boolean isCompoundCurve( Curve geometry ) {
if ( geometry.getCurveType() == CurveType.LineString ) {
return false;
} else if ( geometry.getCurveType() == CurveType.Ring ) {
return isCompoundRing( (Ring) geometry );
} else if ( geometry.getCurveType() == CurveType.Curve ) {
List<CurveSegment> segments = geometry.getCurveSegments();
if ( segments.size() > 1 )
return true;

for ( CurveSegment seg : segments ) {
if ( seg.getSegmentType() != CurveSegmentType.LINE_STRING_SEGMENT ) {
return true;
}
}
}
return true;
}
}
Loading