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

Fix to allow inserting 3d #693

Merged
merged 4 commits into from
Aug 17, 2016
Merged
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 @@ -67,12 +67,14 @@ public static byte[] write( Geometry geom )
geom = ( (GeometryReference<Geometry>) geom ).getReferencedObject();
}
// com.vividsolutions.jts.io.WKBWriter is not thread safe
return new com.vividsolutions.jts.io.WKBWriter().write( ( (AbstractDefaultGeometry) geom ).getJTSGeometry() );
int dim = geom.getCoordinateDimension();
return new com.vividsolutions.jts.io.WKBWriter(dim).write( ( (AbstractDefaultGeometry) geom ).getJTSGeometry() );
}

public static void write( Geometry geom, OutputStream os )
throws IOException, ParseException {
// com.vividsolutions.jts.io.WKBWriter is not thread safe
//TODO: test for dimentionality here aswell?
new com.vividsolutions.jts.io.WKBWriter().write( ( (AbstractDefaultGeometry) geom ).getJTSGeometry(),
new OutputStreamOutStream( os ) );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,15 @@ public static void write( Geometry geom, Writer writer )
if ( writer == null ) {
throw new NullPointerException( "The writer may not be null." );
}
WKTWriter wktW = new WKTWriter( null, null );
Set<WKTFlag> flags = new HashSet<WKTFlag>();
int dim =geom.getCoordinateDimension();
if (dim == 3){
flags.add( WKTWriter.WKTFlag.USE_3D );
}
else{
flags = null;
}
WKTWriter wktW = new WKTWriter( flags, null );
wktW.writeGeometry( geom, writer );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public MappedSchemaBuilderGML( String configURL, List<String> gmlSchemas, Storag
gmlSchema = buildGMLSchema( configURL, gmlSchemas );

CRSRef crs = CRSManager.getCRSRef( storageCRS.getValue() );
CoordinateDimension dim = crs.getDimension() == 3 ? DIM_2 : DIM_3;
CoordinateDimension dim = crs.getDimension() == 3 ? DIM_3 : DIM_2;
geometryParams = new GeometryStorageParams( crs, storageCRS.getSrid(), dim );

// add namespace bindings
Expand Down