Revision 40416
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/operation/towkb/ToWKB.java | ||
---|---|---|
9 | 9 |
import com.vividsolutions.jts.io.WKBWriter; |
10 | 10 |
|
11 | 11 |
public class ToWKB extends GeometryOperation { |
12 |
public static final String NAME = "toWKB"; |
|
13 |
public static final int CODE = GeometryLocator.getGeometryManager(). |
|
14 |
getGeometryOperationCode(NAME); |
|
15 |
|
|
16 |
private static WKBWriter writer = new WKBWriter(); |
|
12 |
public static final String NAME = "toWKB"; |
|
13 |
public static final int CODE = GeometryLocator.getGeometryManager().getGeometryOperationCode(NAME); |
|
14 |
private static WKBWriter writer = null; |
|
15 |
private static int dimension = 2; |
|
17 | 16 |
|
18 | 17 |
public Object invoke(Geometry geom, GeometryOperationContext ctx) { |
18 |
int subType = geom.getGeometryType().getSubType(); |
|
19 |
boolean is3D = subType == 1 || subType == 3; |
|
20 |
|
|
21 |
if(writer == null) { |
|
22 |
if(is3D) { |
|
23 |
dimension = 3; |
|
24 |
writer = new WKBWriter(3); |
|
25 |
} else { |
|
26 |
dimension = 2; |
|
27 |
writer = new WKBWriter(); |
|
28 |
} |
|
29 |
} else { |
|
30 |
if(is3D && dimension == 2) { |
|
31 |
dimension = 3; |
|
32 |
writer = new WKBWriter(3); |
|
33 |
} |
|
34 |
if(!is3D && dimension == 3) { |
|
35 |
dimension = 2; |
|
36 |
writer = new WKBWriter(); |
|
37 |
} |
|
38 |
} |
|
39 |
|
|
19 | 40 |
if (ctx == null){ |
20 | 41 |
return writer.write(Converter.geometryToJts(geom)); |
21 | 42 |
} |
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/impl/AbstractPrimitive.java | ||
---|---|---|
539 | 539 |
|
540 | 540 |
public byte[] convertToWKB(int srs) throws GeometryOperationNotSupportedException, |
541 | 541 |
GeometryOperationException { |
542 |
WKBWriter write = new WKBWriter(); |
|
542 |
int subType = getGeometryType().getSubType(); |
|
543 |
boolean is3D = subType == 1 || subType == 3; |
|
544 |
|
|
545 |
WKBWriter write = null; |
|
546 |
if(is3D) |
|
547 |
write = new WKBWriter(3); |
|
548 |
else |
|
549 |
write = new WKBWriter(2); |
|
543 | 550 |
return write.write(Converter.geometryToJtsWithSRID(this,srs)); |
544 | 551 |
} |
545 | 552 |
|
Also available in: Unified diff