Revision 45683 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/operation/fromwkb/FromWKB.java
FromWKB.java | ||
---|---|---|
21 | 21 |
* For any additional information, do not hesitate to contact us |
22 | 22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
23 | 23 |
*/ |
24 |
|
|
25 | 24 |
package org.gvsig.fmap.geom.jts.operation.fromwkb; |
26 | 25 |
|
27 | 26 |
import org.gvsig.fmap.geom.Geometry; |
28 | 27 |
import org.gvsig.fmap.geom.GeometryLocator; |
29 | 28 |
import org.gvsig.fmap.geom.GeometryManager; |
30 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
31 | 29 |
import org.gvsig.fmap.geom.operation.GeometryOperation; |
32 | 30 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
33 | 31 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
32 |
import org.slf4j.Logger; |
|
33 |
import org.slf4j.LoggerFactory; |
|
34 | 34 |
|
35 |
@SuppressWarnings("UseSpecificCatch") |
|
36 |
public class FromWKB extends GeometryOperation { |
|
35 | 37 |
|
36 |
/** |
|
37 |
* |
|
38 |
* |
|
39 |
* @author Vicente Caballero Navarro |
|
40 |
*/ |
|
41 |
public class FromWKB extends GeometryOperation { |
|
38 |
private static final Logger LOGGER = LoggerFactory.getLogger(FromWKB.class); |
|
39 |
|
|
42 | 40 |
public static final String NAME = GeometryManager.OPERATIONS.FROMWKB; |
41 |
|
|
42 |
public static final int CODE = GeometryLocator.getGeometryManager(). |
|
43 |
getGeometryOperationCode(NAME); |
|
44 |
|
|
45 |
|
|
46 |
private PostGISEWKBParser parser; |
|
47 |
|
|
48 |
public FromWKB() { |
|
49 |
// this.parser = new PostGISEWKBParser(); |
|
50 |
} |
|
43 | 51 |
|
44 |
public static final int CODE = GeometryLocator.getGeometryManager(). |
|
45 |
getGeometryOperationCode(NAME); |
|
46 |
private static PostGISEWKBParser wkbParser = new PostGISEWKBParser(); |
|
47 |
|
|
48 |
/* |
|
52 |
/* |
|
49 | 53 |
* Como no tenemos un parser de OGC-WKB que es distinto del PostGIS-EWKB |
50 | 54 |
* de momento, usamos el de PostGIS-EWKB |
51 | 55 |
* |
... | ... | |
53 | 57 |
* https://en.wikipedia.org/wiki/Well-known_text#Well-known_binary |
54 | 58 |
* |
55 | 59 |
* Podemos asumir que si el 5? byte del WKB es distinto de 0 se trata de PostGIS-EWKB |
56 |
*/ |
|
60 |
*/ |
|
61 |
@Override |
|
57 | 62 |
public Object invoke(Geometry geom, GeometryOperationContext ctx) |
58 |
throws GeometryOperationException { |
|
59 |
byte[] data = (byte[])ctx.getAttribute("data"); |
|
63 |
throws GeometryOperationException { |
|
60 | 64 |
|
61 | 65 |
try { |
62 |
return geom = wkbParser.parse(data); |
|
63 |
} catch (CreateGeometryException e) { |
|
64 |
return new GeometryOperationException(e); |
|
65 |
} |
|
66 |
byte[] wkb = (byte[]) ctx.getAttribute("data"); |
|
67 |
this.parser = new PostGISEWKBParser(); |
|
68 |
Geometry g = parser.parse(wkb); |
|
69 |
return g; |
|
70 |
} catch (Exception e) { |
|
71 |
throw new GeometryOperationException(e); |
|
72 |
} |
|
66 | 73 |
} |
67 | 74 |
|
68 |
/* (non-Javadoc) |
|
69 |
* @see org.gvsig.fmap.geom.operation.GeometryOperation#getOperationIndex() |
|
70 |
*/ |
|
75 |
@Override |
|
71 | 76 |
public int getOperationIndex() { |
72 | 77 |
return CODE; |
73 | 78 |
} |
Also available in: Unified diff