Revision 47755
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/AbstractGeometry.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
import com.vividsolutions.jts.algorithm.CGAlgorithms; |
26 | 26 |
import com.vividsolutions.jts.geom.Coordinate; |
27 |
import com.vividsolutions.jts.io.geojson.GeoJsonWriter; |
|
28 | 27 |
import com.vividsolutions.jts.operation.buffer.BufferParameters; |
29 | 28 |
import com.vividsolutions.jts.operation.distance.DistanceOp; |
30 | 29 |
import com.vividsolutions.jts.operation.overlay.snap.GeometrySnapper; |
... | ... | |
34 | 33 |
import java.awt.Shape; |
35 | 34 |
import java.awt.geom.AffineTransform; |
36 | 35 |
import java.awt.geom.Rectangle2D; |
36 |
import java.util.Map; |
|
37 | 37 |
import org.apache.commons.codec.binary.Hex; |
38 | 38 |
import org.apache.commons.lang3.StringUtils; |
39 | 39 |
import org.cresques.cts.IProjection; |
... | ... | |
46 | 46 |
import org.gvsig.fmap.geom.aggregate.MultiPrimitive; |
47 | 47 |
import org.gvsig.fmap.geom.complex.Complex; |
48 | 48 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
49 |
import org.gvsig.fmap.geom.jts.formats.geojson.GeoJsonWriter; |
|
50 |
import org.gvsig.fmap.geom.jts.formats.geojson.GeoJsonWriterEx; |
|
49 | 51 |
import org.gvsig.fmap.geom.jts.operation.towkb.OGCWKBEncoder; |
50 | 52 |
import org.gvsig.fmap.geom.jts.operation.towkb.PostGISEWKBEncoder; |
51 | 53 |
import org.gvsig.fmap.geom.jts.operation.towkt.EWKTWriter; |
... | ... | |
57 | 59 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
58 | 60 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
59 | 61 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
60 |
import org.gvsig.fmap.geom.primitive.Curve; |
|
61 | 62 |
import org.gvsig.fmap.geom.primitive.Envelope; |
62 | 63 |
import org.gvsig.fmap.geom.primitive.OrientableCurve; |
63 | 64 |
import org.gvsig.fmap.geom.primitive.OrientablePrimitive; |
64 | 65 |
import org.gvsig.fmap.geom.primitive.OrientableSurface; |
65 | 66 |
import org.gvsig.fmap.geom.primitive.Point; |
66 | 67 |
import org.gvsig.fmap.geom.type.GeometryType; |
67 |
import org.gvsig.tools.util.IsEmpty; |
|
68 | 68 |
import org.slf4j.Logger; |
69 | 69 |
import org.slf4j.LoggerFactory; |
70 | 70 |
|
... | ... | |
329 | 329 |
coord[2] = new com.vividsolutions.jts.geom.Coordinate(x + w, y + w); |
330 | 330 |
coord[3] = new com.vividsolutions.jts.geom.Coordinate(x, y + w); |
331 | 331 |
coord[4] = new com.vividsolutions.jts.geom.Coordinate(x, y); |
332 |
rect = JTSUtils.createJTSPolygon(coord); |
|
332 |
rect = JTSUtils.createJTSPolygon(getProjection(), coord);
|
|
333 | 333 |
|
334 | 334 |
return getJTS().intersects(rect); |
335 | 335 |
} |
... | ... | |
453 | 453 |
} |
454 | 454 |
|
455 | 455 |
@Override |
456 |
public Object convertTo(String format) throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
456 |
public Object convertTo(String format, Object...args) throws GeometryOperationNotSupportedException, GeometryOperationException {
|
|
457 | 457 |
if( StringUtils.isEmpty(format) ) { |
458 | 458 |
throw new IllegalArgumentException("Can't accept null as format name."); |
459 | 459 |
} |
... | ... | |
473 | 473 |
return GMLUtils.geometry2GML(this); |
474 | 474 |
case "json": |
475 | 475 |
case "geojson": |
476 |
if( args!=null ) { |
|
477 |
if( args.length>=1 && args[0] instanceof Map ) { |
|
478 |
if( args.length>=2 && args[1] instanceof Boolean ) { |
|
479 |
return this.convertToGeoJson((Map<String,Object>)(args[0]), (boolean)(args[1])); |
|
480 |
} |
|
481 |
return this.convertToGeoJson((Map<String,Object>)(args[0]), true); |
|
482 |
} |
|
483 |
} |
|
476 | 484 |
return this.convertToGeoJson(); |
477 | 485 |
default: |
478 | 486 |
throw new IllegalArgumentException("Format '"+format+"' not supported"); |
... | ... | |
510 | 518 |
} |
511 | 519 |
|
512 | 520 |
@Override |
521 |
public String convertToGeoJson(Map<String,Object>properties, boolean encodecrs) throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
522 |
try { |
|
523 |
GeoJsonWriterEx writer = new GeoJsonWriterEx(); |
|
524 |
writer.setEncodeCRS(true); |
|
525 |
return writer.write(this.getJTS(), properties); |
|
526 |
} catch (Exception e) { |
|
527 |
throw new GeometryOperationException(e); |
|
528 |
} |
|
529 |
} |
|
530 |
|
|
531 |
@Override |
|
513 | 532 |
public String convertToHexEWKB() throws GeometryOperationNotSupportedException, GeometryOperationException { |
514 | 533 |
try { |
515 | 534 |
byte[] bytes = new PostGISEWKBEncoder().encode(this); |
... | ... | |
1080 | 1099 |
} |
1081 | 1100 |
return false; |
1082 | 1101 |
} |
1102 |
|
|
1103 |
|
|
1083 | 1104 |
|
1084 |
|
|
1085 |
|
|
1086 | 1105 |
} |
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/primitive/point/AbstractPoint.java | ||
---|---|---|
198 | 198 |
* @see org.gvsig.fmap.geom.jts.GeometryJTS#getJTS() |
199 | 199 |
*/ |
200 | 200 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
201 |
return JTSUtils.createJTSPoint(this.coordinate); |
|
201 |
return JTSUtils.createJTSPoint(getProjection(), this.coordinate);
|
|
202 | 202 |
} |
203 | 203 |
|
204 | 204 |
/* |
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/primitive/ring/Ring2D.java | ||
---|---|---|
110 | 110 |
*/ |
111 | 111 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
112 | 112 |
closePrimitive(); |
113 |
return JTSUtils.createJTSLinearRing(coordinates); |
|
113 |
return JTSUtils.createJTSLinearRing(getProjection(), coordinates);
|
|
114 | 114 |
} |
115 | 115 |
|
116 | 116 |
|
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/primitive/ring/Ring3D.java | ||
---|---|---|
110 | 110 |
* @see org.gvsig.fmap.geom.jts.GeometryJTS#getJTS() |
111 | 111 |
*/ |
112 | 112 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
113 |
return JTSUtils.createJTSLinearRing(coordinates); |
|
113 |
return JTSUtils.createJTSLinearRing(getProjection(), coordinates);
|
|
114 | 114 |
} |
115 | 115 |
|
116 | 116 |
/* (non-Javadoc) |
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/primitive/ring/Ring2DM.java | ||
---|---|---|
106 | 106 |
* @see org.gvsig.fmap.geom.jts.GeometryJTS#getJTS() |
107 | 107 |
*/ |
108 | 108 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
109 |
return JTSUtils.createJTSLinearRing(coordinates); |
|
109 |
return JTSUtils.createJTSLinearRing(getProjection(), coordinates);
|
|
110 | 110 |
} |
111 | 111 |
|
112 | 112 |
/* (non-Javadoc) |
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/primitive/ring/Ring3DM.java | ||
---|---|---|
112 | 112 |
* @see org.gvsig.fmap.geom.jts.GeometryJTS#getJTS() |
113 | 113 |
*/ |
114 | 114 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
115 |
return JTSUtils.createJTSLinearRing(coordinates); |
|
115 |
return JTSUtils.createJTSLinearRing(getProjection(), coordinates);
|
|
116 | 116 |
} |
117 | 117 |
|
118 | 118 |
/* (non-Javadoc) |
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/primitive/DefaultEnvelope.java | ||
---|---|---|
448 | 448 |
coordinates.add(new com.vividsolutions.jts.geom.Coordinate(max.getX(), max.getY())); |
449 | 449 |
coordinates.add(new com.vividsolutions.jts.geom.Coordinate(getMinimum(0), getMaximum(1))); |
450 | 450 |
coordinates.add(new com.vividsolutions.jts.geom.Coordinate(min.getX(), min.getY())); |
451 |
jtsGeom = JTSUtils.createJTSPolygon(coordinates); |
|
451 |
jtsGeom = JTSUtils.createJTSPolygon(getProjection(), coordinates);
|
|
452 | 452 |
} |
453 | 453 |
return jtsGeom; |
454 | 454 |
} |
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/primitive/curve/arc/Arc2DZ.java | ||
---|---|---|
177 | 177 |
} |
178 | 178 |
pi.next(); |
179 | 179 |
} |
180 |
return JTSUtils.createJTSLineString(coordinates); |
|
180 |
return JTSUtils.createJTSLineString(getProjection(), coordinates);
|
|
181 | 181 |
} |
182 | 182 |
|
183 | 183 |
/* (non-Javadoc) |
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/primitive/curve/arc/Arc2DM.java | ||
---|---|---|
184 | 184 |
} |
185 | 185 |
pi.next(); |
186 | 186 |
} |
187 |
return JTSUtils.createJTSLineString(coordinates); |
|
187 |
return JTSUtils.createJTSLineString(getProjection(), coordinates);
|
|
188 | 188 |
} |
189 | 189 |
|
190 | 190 |
/* (non-Javadoc) |
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/primitive/curve/arc/Arc2D.java | ||
---|---|---|
158 | 158 |
} |
159 | 159 |
pi.next(); |
160 | 160 |
} |
161 |
return JTSUtils.createJTSLineString(coordinates); |
|
161 |
return JTSUtils.createJTSLineString(getProjection(), coordinates);
|
|
162 | 162 |
} |
163 | 163 |
|
164 | 164 |
/* (non-Javadoc) |
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/primitive/curve/arc/Arc2DZM.java | ||
---|---|---|
192 | 192 |
} |
193 | 193 |
pi.next(); |
194 | 194 |
} |
195 |
return JTSUtils.createJTSLineString(coordinates); |
|
195 |
return JTSUtils.createJTSLineString(getProjection(), coordinates);
|
|
196 | 196 |
} |
197 | 197 |
|
198 | 198 |
/* (non-Javadoc) |
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/primitive/curve/line/AbstractLine.java | ||
---|---|---|
123 | 123 |
|
124 | 124 |
@Override |
125 | 125 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
126 |
return JTSUtils.createJTSLineString(coordinates); |
|
126 |
return JTSUtils.createJTSLineString(getProjection(), coordinates);
|
|
127 | 127 |
} |
128 | 128 |
|
129 | 129 |
@Override |
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/primitive/curve/circumference/Circumference2DZM.java | ||
---|---|---|
57 | 57 |
*/ |
58 | 58 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
59 | 59 |
ArrayListCoordinateSequence coordinates = getJTSCoordinates(); |
60 |
return JTSUtils.createJTSLineString(coordinates); |
|
60 |
return JTSUtils.createJTSLineString(getProjection(), coordinates);
|
|
61 | 61 |
} |
62 | 62 |
|
63 | 63 |
|
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/primitive/curve/circumference/Circumference2DZ.java | ||
---|---|---|
62 | 62 |
*/ |
63 | 63 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
64 | 64 |
ArrayListCoordinateSequence coordinates = getJTSCoordinates(); |
65 |
return JTSUtils.createJTSLineString(coordinates); |
|
65 |
return JTSUtils.createJTSLineString(getProjection(), coordinates);
|
|
66 | 66 |
} |
67 | 67 |
|
68 | 68 |
|
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/primitive/curve/circumference/Circumference2DM.java | ||
---|---|---|
57 | 57 |
*/ |
58 | 58 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
59 | 59 |
ArrayListCoordinateSequence coordinates = getJTSCoordinates(); |
60 |
return JTSUtils.createJTSLineString(coordinates); |
|
60 |
return JTSUtils.createJTSLineString(getProjection(), coordinates);
|
|
61 | 61 |
} |
62 | 62 |
|
63 | 63 |
|
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/primitive/curve/circumference/Circumference2D.java | ||
---|---|---|
65 | 65 |
*/ |
66 | 66 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
67 | 67 |
ArrayListCoordinateSequence coordinates = getJTSCoordinates(); |
68 |
return JTSUtils.createJTSLineString(coordinates); |
|
68 |
return JTSUtils.createJTSLineString(getProjection(), coordinates);
|
|
69 | 69 |
} |
70 | 70 |
|
71 | 71 |
|
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/primitive/curve/spline/AbstractSpline.java | ||
---|---|---|
87 | 87 |
|
88 | 88 |
@Override |
89 | 89 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
90 |
return JTSUtils.createJTSLineString(getSplineCoordinates()); |
|
90 |
return JTSUtils.createJTSLineString(getProjection(), getSplineCoordinates());
|
|
91 | 91 |
} |
92 | 92 |
|
93 | 93 |
protected abstract ArrayListCoordinateSequence getSplineCoordinates(); |
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/primitive/curve/periellipse/PeriEllipse2DZM.java | ||
---|---|---|
68 | 68 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
69 | 69 |
ArrayListCoordinateSequence coordinates = getJTSCoordinates(); |
70 | 70 |
//Ellipse's getJTSCoordinates return the coordinates in reverse order |
71 |
LineString g = JTSUtils.createJTSLineString(coordinates); |
|
71 |
LineString g = JTSUtils.createJTSLineString(getProjection(), coordinates);
|
|
72 | 72 |
return g.reverse(); |
73 | 73 |
} |
74 | 74 |
|
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/primitive/curve/periellipse/PeriEllipse2DZ.java | ||
---|---|---|
73 | 73 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
74 | 74 |
ArrayListCoordinateSequence coordinates = getJTSCoordinates(); |
75 | 75 |
//Ellipse's getJTSCoordinates return the coordinates in reverse order |
76 |
LineString g = JTSUtils.createJTSLineString(coordinates); |
|
76 |
LineString g = JTSUtils.createJTSLineString(getProjection(), coordinates);
|
|
77 | 77 |
return g.reverse(); |
78 | 78 |
} |
79 | 79 |
|
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/primitive/curve/periellipse/PeriEllipse2DM.java | ||
---|---|---|
68 | 68 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
69 | 69 |
ArrayListCoordinateSequence coordinates = getJTSCoordinates(); |
70 | 70 |
//Ellipse's getJTSCoordinates return the coordinates in reverse order |
71 |
LineString g = JTSUtils.createJTSLineString(coordinates); |
|
71 |
LineString g = JTSUtils.createJTSLineString(getProjection(), coordinates);
|
|
72 | 72 |
return g.reverse(); |
73 | 73 |
} |
74 | 74 |
|
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/primitive/curve/periellipse/PeriEllipse2D.java | ||
---|---|---|
104 | 104 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
105 | 105 |
ArrayListCoordinateSequence coordinates = getJTSCoordinates(); |
106 | 106 |
//Ellipse's getJTSCoordinates return the coordinates in reverse order |
107 |
LineString g = JTSUtils.createJTSLineString(coordinates); |
|
107 |
LineString g = JTSUtils.createJTSLineString(getProjection(), coordinates);
|
|
108 | 108 |
return g.reverse(); |
109 | 109 |
} |
110 | 110 |
|
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/primitive/surface/filledspline/FilledSpline2DM.java | ||
---|---|---|
157 | 157 |
* @see org.gvsig.fmap.geom.jts.GeometryJTS#getJTS() |
158 | 158 |
*/ |
159 | 159 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
160 |
return JTSUtils.createJTSPolygon(getSplineCoordinates()); |
|
160 |
return JTSUtils.createJTSPolygon(getProjection(), getSplineCoordinates());
|
|
161 | 161 |
} |
162 | 162 |
|
163 | 163 |
|
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/primitive/surface/filledspline/FilledSpline3DM.java | ||
---|---|---|
160 | 160 |
* @see org.gvsig.fmap.geom.jts.GeometryJTS#getJTS() |
161 | 161 |
*/ |
162 | 162 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
163 |
return JTSUtils.createJTSPolygon(getSplineCoordinates()); |
|
163 |
return JTSUtils.createJTSPolygon(getProjection(), getSplineCoordinates());
|
|
164 | 164 |
} |
165 | 165 |
|
166 | 166 |
|
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/primitive/surface/filledspline/FilledSpline2D.java | ||
---|---|---|
125 | 125 |
} |
126 | 126 |
|
127 | 127 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
128 |
return JTSUtils.createJTSPolygon(getSplineCoordinates()); |
|
128 |
return JTSUtils.createJTSPolygon(getProjection(), getSplineCoordinates());
|
|
129 | 129 |
} |
130 | 130 |
|
131 | 131 |
public Geometry offset(double distance) throws GeometryOperationNotSupportedException, GeometryOperationException { |
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/primitive/surface/filledspline/FilledSpline3D.java | ||
---|---|---|
159 | 159 |
* @see org.gvsig.fmap.geom.jts.GeometryJTS#getJTS() |
160 | 160 |
*/ |
161 | 161 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
162 |
return JTSUtils.createJTSPolygon(getSplineCoordinates()); |
|
162 |
return JTSUtils.createJTSPolygon(getProjection(), getSplineCoordinates());
|
|
163 | 163 |
} |
164 | 164 |
|
165 | 165 |
|
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/primitive/surface/ellipticarc/EllipticArc2DM.java | ||
---|---|---|
59 | 59 |
*/ |
60 | 60 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
61 | 61 |
ArrayListCoordinateSequence coordinates = getJTSCoordinates(); |
62 |
return JTSUtils.createJTSPolygon(coordinates); |
|
62 |
return JTSUtils.createJTSPolygon(getProjection(), coordinates);
|
|
63 | 63 |
} |
64 | 64 |
} |
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/primitive/surface/ellipticarc/EllipticArc2D.java | ||
---|---|---|
64 | 64 |
*/ |
65 | 65 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
66 | 66 |
ArrayListCoordinateSequence coordinates = getJTSCoordinates(); |
67 |
return JTSUtils.createJTSPolygon(coordinates); |
|
67 |
return JTSUtils.createJTSPolygon(getProjection(), coordinates);
|
|
68 | 68 |
} |
69 | 69 |
} |
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/primitive/surface/ellipticarc/EllipticArc2DZM.java | ||
---|---|---|
59 | 59 |
*/ |
60 | 60 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
61 | 61 |
ArrayListCoordinateSequence coordinates = getJTSCoordinates(); |
62 |
return JTSUtils.createJTSPolygon(coordinates); |
|
62 |
return JTSUtils.createJTSPolygon(getProjection(), coordinates);
|
|
63 | 63 |
} |
64 | 64 |
} |
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/primitive/surface/ellipticarc/EllipticArc2DZ.java | ||
---|---|---|
59 | 59 |
*/ |
60 | 60 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
61 | 61 |
ArrayListCoordinateSequence coordinates = getJTSCoordinates(); |
62 |
return JTSUtils.createJTSPolygon(coordinates); |
|
62 |
return JTSUtils.createJTSPolygon(getProjection(), coordinates);
|
|
63 | 63 |
} |
64 | 64 |
} |
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/primitive/surface/ellipse/Ellipse2DZM.java | ||
---|---|---|
65 | 65 |
@Override |
66 | 66 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
67 | 67 |
ArrayListCoordinateSequence coordinates = getJTSCoordinates(); |
68 |
return JTSUtils.createJTSPolygon(coordinates); |
|
68 |
return JTSUtils.createJTSPolygon(getProjection(), coordinates);
|
|
69 | 69 |
} |
70 | 70 |
|
71 | 71 |
|
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/primitive/surface/ellipse/Ellipse2DZ.java | ||
---|---|---|
72 | 72 |
*/ |
73 | 73 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
74 | 74 |
ArrayListCoordinateSequence coordinates = getJTSCoordinates(); |
75 |
return JTSUtils.createJTSPolygon(coordinates); |
|
75 |
return JTSUtils.createJTSPolygon(getProjection(), coordinates);
|
|
76 | 76 |
} |
77 | 77 |
|
78 | 78 |
|
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/primitive/surface/ellipse/Ellipse2DM.java | ||
---|---|---|
65 | 65 |
@Override |
66 | 66 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
67 | 67 |
ArrayListCoordinateSequence coordinates = getJTSCoordinates(); |
68 |
return JTSUtils.createJTSPolygon(coordinates); |
|
68 |
return JTSUtils.createJTSPolygon(getProjection(), coordinates);
|
|
69 | 69 |
} |
70 | 70 |
|
71 | 71 |
|
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/primitive/surface/ellipse/Ellipse2D.java | ||
---|---|---|
72 | 72 |
*/ |
73 | 73 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
74 | 74 |
ArrayListCoordinateSequence coordinates = getJTSCoordinates(); |
75 |
return JTSUtils.createJTSPolygon(coordinates); |
|
75 |
return JTSUtils.createJTSPolygon(getProjection(), coordinates);
|
|
76 | 76 |
} |
77 | 77 |
|
78 | 78 |
|
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/primitive/surface/circle/Circle2DZM.java | ||
---|---|---|
58 | 58 |
*/ |
59 | 59 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
60 | 60 |
ArrayListCoordinateSequence coordinates = getJTSCoordinates(); |
61 |
return JTSUtils.createJTSPolygon(coordinates); |
|
61 |
return JTSUtils.createJTSPolygon(getProjection(), coordinates);
|
|
62 | 62 |
} |
63 | 63 |
|
64 | 64 |
|
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/primitive/surface/circle/Circle2DZ.java | ||
---|---|---|
62 | 62 |
*/ |
63 | 63 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
64 | 64 |
ArrayListCoordinateSequence coordinates = getJTSCoordinates(); |
65 |
return JTSUtils.createJTSPolygon(coordinates); |
|
65 |
return JTSUtils.createJTSPolygon(getProjection(), coordinates);
|
|
66 | 66 |
} |
67 | 67 |
|
68 | 68 |
|
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/primitive/surface/circle/Circle2DM.java | ||
---|---|---|
58 | 58 |
*/ |
59 | 59 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
60 | 60 |
ArrayListCoordinateSequence coordinates = getJTSCoordinates(); |
61 |
return JTSUtils.createJTSPolygon(coordinates); |
|
61 |
return JTSUtils.createJTSPolygon(getProjection(), coordinates);
|
|
62 | 62 |
} |
63 | 63 |
|
64 | 64 |
|
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/primitive/surface/circle/Circle2D.java | ||
---|---|---|
65 | 65 |
*/ |
66 | 66 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
67 | 67 |
ArrayListCoordinateSequence coordinates = getJTSCoordinates(); |
68 |
return JTSUtils.createJTSPolygon(coordinates); |
|
68 |
return JTSUtils.createJTSPolygon(getProjection(), coordinates);
|
|
69 | 69 |
} |
70 | 70 |
|
71 | 71 |
|
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/primitive/surface/polygon/Polygon2DM.java | ||
---|---|---|
265 | 265 |
* @see org.gvsig.fmap.geom.jts.GeometryJTS#getJTS() |
266 | 266 |
*/ |
267 | 267 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
268 |
return JTSUtils.createJTSPolygon(coordinates, interiorRings); |
|
268 |
return JTSUtils.createJTSPolygon(getProjection(), coordinates, interiorRings);
|
|
269 | 269 |
} |
270 | 270 |
|
271 | 271 |
|
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/primitive/surface/polygon/Polygon3DM.java | ||
---|---|---|
268 | 268 |
* @see org.gvsig.fmap.geom.jts.GeometryJTS#getJTS() |
269 | 269 |
*/ |
270 | 270 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
271 |
return JTSUtils.createJTSPolygon(coordinates, interiorRings); |
|
271 |
return JTSUtils.createJTSPolygon(getProjection(), coordinates, interiorRings);
|
|
272 | 272 |
} |
273 | 273 |
|
274 | 274 |
|
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/primitive/surface/polygon/Polygon2D.java | ||
---|---|---|
286 | 286 |
* @see org.gvsig.fmap.geom.jts.GeometryJTS#getJTS() |
287 | 287 |
*/ |
288 | 288 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
289 |
return JTSUtils.createJTSPolygon(coordinates, interiorRings); |
|
289 |
return JTSUtils.createJTSPolygon(getProjection(), coordinates, interiorRings);
|
|
290 | 290 |
} |
291 | 291 |
|
292 | 292 |
/* |
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/primitive/surface/polygon/Polygon3D.java | ||
---|---|---|
264 | 264 |
* @see org.gvsig.fmap.geom.jts.GeometryJTS#getJTS() |
265 | 265 |
*/ |
266 | 266 |
public com.vividsolutions.jts.geom.Geometry getJTS() { |
267 |
return JTSUtils.createJTSPolygon(coordinates, interiorRings); |
|
267 |
return JTSUtils.createJTSPolygon(getProjection(), coordinates, interiorRings);
|
|
268 | 268 |
} |
269 | 269 |
|
270 | 270 |
/* |
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/DefaultGeometryManager.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
package org.gvsig.fmap.geom.jts; |
26 | 26 |
|
27 |
import com.vividsolutions.jts.io.ParseException; |
|
27 | 28 |
import java.awt.geom.PathIterator; |
28 | 29 |
import java.io.IOException; |
29 | 30 |
import java.io.Reader; |
... | ... | |
32 | 33 |
import java.util.Iterator; |
33 | 34 |
import java.util.List; |
34 | 35 |
import java.util.Map; |
36 |
import javax.json.JsonObject; |
|
35 | 37 |
import org.apache.commons.codec.binary.Hex; |
36 | 38 |
import org.apache.commons.io.IOUtils; |
37 | 39 |
import org.apache.commons.lang3.StringUtils; |
... | ... | |
743 | 745 |
if( data instanceof Geometry ) { |
744 | 746 |
return ((Geometry)data).cloneGeometry(); |
745 | 747 |
} |
748 |
if( data instanceof JsonObject ) { |
|
749 |
return this.createFrom((JsonObject)data, null); |
|
750 |
} |
|
746 | 751 |
throw new IllegalArgumentException("Type of data ("+data.getClass().getName()+") not supported."); |
747 | 752 |
} |
748 | 753 |
|
754 |
public Geometry createFrom(JsonObject json, IProjection srs) throws CreateGeometryException, GeometryException { |
|
755 |
try { |
|
756 |
// TODO: Create geometry from a Json object now converts the json to a string and calls the jts geojson parser. |
|
757 |
// TODO: We should implement a geometry parser of a JsonObject directly. |
|
758 |
com.vividsolutions.jts.io.geojson.GeoJsonReader reader = new com.vividsolutions.jts.io.geojson.GeoJsonReader(); |
|
759 |
com.vividsolutions.jts.geom.Geometry geom_jts = reader.read(json.toString()); |
|
760 |
return JTSUtils.createGeometry(srs, geom_jts); |
|
761 |
} catch (ParseException ex) { |
|
762 |
throw new GeometryException(ex); |
|
763 |
} |
|
764 |
} |
|
765 |
|
|
749 | 766 |
@Override |
750 | 767 |
public Geometry createFrom(String wkt, String srs) throws GeometryException { |
751 | 768 |
GeometryOperationContext context = new GeometryOperationContext(); |
... | ... | |
892 | 909 |
return this.createFrom(wkt, (IProjection)null); |
893 | 910 |
} |
894 | 911 |
|
895 |
public Geometry createFrom(IProjection proj, com.vividsolutions.jts.geom.Geometry geom) throws GeometryException { |
|
896 |
return JTSUtils.createGeometry(proj, geom); |
|
897 |
} |
|
912 |
// public Geometry createFrom(IProjection proj, com.vividsolutions.jts.geom.Geometry geom) throws GeometryException {
|
|
913 |
// return JTSUtils.createGeometry(proj, geom);
|
|
914 |
// }
|
|
898 | 915 |
|
899 | 916 |
@Override |
900 | 917 |
public Geometry createFromQuietly(String wkt) { |
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/formats/geojson/GeoJsonWriterEx.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.fmap.geom.jts.formats.geojson; |
|
7 |
|
|
8 |
import com.vividsolutions.jts.geom.Geometry; |
|
9 |
import com.vividsolutions.jts.util.Assert; |
|
10 |
import java.io.IOException; |
|
11 |
import java.io.StringWriter; |
|
12 |
import java.io.Writer; |
|
13 |
import java.util.LinkedHashMap; |
|
14 |
import java.util.Map; |
|
15 |
import org.json.simple.JSONObject; |
|
16 |
|
|
17 |
/** |
|
18 |
* |
|
19 |
* @author jjdelcerro |
|
20 |
*/ |
|
21 |
public class GeoJsonWriterEx extends GeoJsonWriter { |
|
22 |
|
|
23 |
public GeoJsonWriterEx() { |
|
24 |
super(8); |
|
25 |
} |
|
26 |
|
|
27 |
/** |
|
28 |
* Constructs a GeoJsonWriter instance specifying the number of decimals to |
|
29 |
* use when encoding floating point numbers. |
|
30 |
*/ |
|
31 |
public GeoJsonWriterEx(int decimals) { |
|
32 |
super(decimals); |
|
33 |
} |
|
34 |
|
|
35 |
public String write(Geometry geometry, Map<String,Object> properties) { |
|
36 |
StringWriter writer = new StringWriter(); |
|
37 |
try { |
|
38 |
write(geometry, properties, writer); |
|
39 |
} catch (IOException ex) { |
|
40 |
Assert.shouldNeverReachHere(); |
|
41 |
} |
|
42 |
|
|
43 |
return writer.toString(); } |
|
44 |
|
|
45 |
public void write(Geometry geometry, Map<String,Object> properties, Writer writer) throws IOException { |
|
46 |
Map<String, Object> feat = new LinkedHashMap<>(); |
|
47 |
Map<String, Object> geom = create(geometry, isEncodeCRS); |
|
48 |
feat.put("type", "Feature"); |
|
49 |
feat.put("geometry", geom); |
|
50 |
feat.put("properties", properties); |
|
51 |
JSONObject.writeJSONString(feat, writer); |
|
52 |
writer.flush(); |
|
53 |
} |
|
54 |
} |
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/formats/geojson/GeoJsonConstants.java | ||
---|---|---|
1 |
package org.gvsig.fmap.geom.jts.formats.geojson; |
|
2 |
|
|
3 |
|
|
4 |
/** |
|
5 |
* Constants for GeoJSON objects |
|
6 |
* |
|
7 |
* @author Martin Davis |
|
8 |
*/ |
|
9 |
public class GeoJsonConstants { |
|
10 |
|
|
11 |
public static final String NAME_GEOMETRIES = "geometries"; |
|
12 |
public static final String NAME_CRS = "crs"; |
|
13 |
public static final String NAME_PROPERTIES = "properties"; |
|
14 |
public static final String NAME_NAME = "name"; |
|
15 |
public static final String NAME_TYPE = "type"; |
|
16 |
public static final String NAME_POINT = "Point"; |
|
17 |
public static final String NAME_LINESTRING = "LineString"; |
|
18 |
public static final String NAME_POLYGON = "Polygon"; |
|
19 |
public static final String NAME_COORDINATES = "coordinates"; |
|
20 |
public static final String NAME_GEOMETRYCOLLECTION = "GeometryCollection"; |
|
21 |
public static final String NAME_MULTIPOLYGON = "MultiPolygon"; |
|
22 |
public static final String NAME_MULTILINESTRING = "MultiLineString"; |
|
23 |
public static final String NAME_MULTIPOINT = "MultiPoint"; |
|
24 |
|
|
25 |
} |
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/formats/geojson/GeoJsonWriter.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.fmap.geom.jts.formats.geojson; |
|
3 |
|
|
4 |
import java.io.IOException; |
|
5 |
import java.io.StringWriter; |
|
6 |
import java.io.Writer; |
|
7 |
import java.util.ArrayList; |
|
8 |
import java.util.LinkedHashMap; |
|
9 |
import java.util.List; |
|
10 |
import java.util.Map; |
|
11 |
|
|
12 |
import org.json.simple.JSONAware; |
|
13 |
import org.json.simple.JSONObject; |
|
14 |
|
|
15 |
import com.vividsolutions.jts.geom.CoordinateSequence; |
|
16 |
import com.vividsolutions.jts.geom.Geometry; |
|
17 |
import com.vividsolutions.jts.geom.GeometryCollection; |
|
18 |
import com.vividsolutions.jts.geom.LineString; |
|
19 |
import com.vividsolutions.jts.geom.MultiLineString; |
|
20 |
import com.vividsolutions.jts.geom.MultiPoint; |
|
21 |
import com.vividsolutions.jts.geom.MultiPolygon; |
|
22 |
import com.vividsolutions.jts.geom.Point; |
|
23 |
import com.vividsolutions.jts.geom.Polygon; |
|
24 |
import com.vividsolutions.jts.util.Assert; |
|
25 |
|
|
26 |
/** |
|
27 |
* Writes {@link Geometry}s as JSON fragments in GeoJson format. |
|
28 |
* |
|
29 |
* @author Martin Davis |
|
30 |
* @author Paul Howells, Vivid Solutions |
|
31 |
*/ |
|
32 |
public class GeoJsonWriter { |
|
33 |
|
|
34 |
public static final String EPSG_PREFIX = "EPSG:"; |
|
35 |
|
|
36 |
private double scale; |
|
37 |
protected boolean isEncodeCRS = true; |
|
38 |
|
|
39 |
/** |
|
40 |
* Constructs a GeoJsonWriter instance. |
|
41 |
*/ |
|
42 |
public GeoJsonWriter() { |
|
43 |
this(8); |
|
44 |
} |
|
45 |
|
|
46 |
/** |
|
47 |
* Constructs a GeoJsonWriter instance specifying the number of decimals to |
|
48 |
* use when encoding floating point numbers. |
|
49 |
*/ |
|
50 |
public GeoJsonWriter(int decimals) { |
|
51 |
this.scale = Math.pow(10, decimals); |
|
52 |
} |
|
53 |
|
|
54 |
public void setEncodeCRS(boolean isEncodeCRS) { |
|
55 |
this.isEncodeCRS = isEncodeCRS; |
|
56 |
} |
|
57 |
|
|
58 |
/** |
|
59 |
* Writes a {@link Geometry} in GeoJson format to a String. |
|
60 |
* |
|
61 |
* @param geometry |
|
62 |
* @return String GeoJson Encoded Geometry |
|
63 |
*/ |
|
64 |
public String write(Geometry geometry) { |
|
65 |
|
|
66 |
StringWriter writer = new StringWriter(); |
|
67 |
try { |
|
68 |
write(geometry, writer); |
|
69 |
} catch (IOException ex) { |
|
70 |
Assert.shouldNeverReachHere(); |
|
71 |
} |
|
72 |
|
|
73 |
return writer.toString(); |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* Writes a {@link Geometry} in GeoJson format into a {@link Writer}. |
|
78 |
* |
|
79 |
* @param geometry |
|
80 |
* Geometry to encode |
|
81 |
* @param writer |
|
82 |
* Stream to encode to. |
|
83 |
* @throws IOException |
|
84 |
* throws an IOException when unable to write the JSON string |
|
85 |
*/ |
|
86 |
public void write(Geometry geometry, Writer writer) throws IOException { |
|
87 |
Map<String, Object> map = create(geometry, isEncodeCRS); |
|
88 |
JSONObject.writeJSONString(map, writer); |
|
89 |
writer.flush(); |
|
90 |
} |
|
91 |
|
|
92 |
protected Map<String, Object> create(Geometry geometry, boolean encodeCRS) { |
|
93 |
|
|
94 |
Map<String, Object> result = new LinkedHashMap<String, Object>(); |
|
95 |
result.put(GeoJsonConstants.NAME_TYPE, geometry.getGeometryType()); |
|
96 |
|
|
97 |
if (geometry instanceof Point) { |
|
98 |
Point point = (Point) geometry; |
|
99 |
|
|
100 |
final String jsonString = getJsonString(point.getCoordinateSequence()); |
|
101 |
|
|
102 |
result.put(GeoJsonConstants.NAME_COORDINATES, new JSONAware() { |
|
103 |
|
|
104 |
public String toJSONString() { |
|
105 |
return jsonString; |
|
106 |
} |
|
107 |
}); |
|
108 |
|
|
109 |
} else if (geometry instanceof LineString) { |
|
110 |
LineString lineString = (LineString) geometry; |
|
111 |
|
|
112 |
final String jsonString = getJsonString(lineString |
|
113 |
.getCoordinateSequence()); |
|
114 |
|
|
115 |
result.put(GeoJsonConstants.NAME_COORDINATES, new JSONAware() { |
|
116 |
|
|
117 |
public String toJSONString() { |
|
118 |
return jsonString; |
|
119 |
} |
|
120 |
}); |
|
121 |
|
|
122 |
} else if (geometry instanceof Polygon) { |
|
123 |
Polygon polygon = (Polygon) geometry; |
|
124 |
|
|
125 |
result.put(GeoJsonConstants.NAME_COORDINATES, makeJsonAware(polygon)); |
|
126 |
|
|
127 |
} else if (geometry instanceof MultiPoint) { |
|
128 |
MultiPoint multiPoint = (MultiPoint) geometry; |
|
129 |
|
|
130 |
result.put(GeoJsonConstants.NAME_COORDINATES, makeJsonAware(multiPoint)); |
|
131 |
|
|
132 |
} else if (geometry instanceof MultiLineString) { |
|
133 |
MultiLineString multiLineString = (MultiLineString) geometry; |
|
134 |
|
|
135 |
result.put(GeoJsonConstants.NAME_COORDINATES, makeJsonAware(multiLineString)); |
|
136 |
|
|
137 |
} else if (geometry instanceof MultiPolygon) { |
|
138 |
MultiPolygon multiPolygon = (MultiPolygon) geometry; |
|
139 |
|
|
140 |
result.put(GeoJsonConstants.NAME_COORDINATES, makeJsonAware(multiPolygon)); |
|
141 |
|
|
142 |
} else if (geometry instanceof GeometryCollection) { |
|
143 |
GeometryCollection geometryCollection = (GeometryCollection) geometry; |
|
144 |
|
|
145 |
ArrayList<Map<String, Object>> geometries = new ArrayList<Map<String, Object>>( |
|
146 |
geometryCollection.getNumGeometries()); |
|
147 |
|
|
148 |
for (int i = 0; i < geometryCollection.getNumGeometries(); i++) { |
|
149 |
geometries.add(create(geometryCollection.getGeometryN(i), false)); |
|
150 |
} |
|
151 |
|
|
152 |
result.put(GeoJsonConstants.NAME_GEOMETRIES, geometries); |
|
153 |
|
|
154 |
} else { |
|
155 |
throw new IllegalArgumentException("Unable to encode geometry " + geometry.getGeometryType() ); |
|
156 |
} |
|
157 |
|
|
158 |
if (encodeCRS) { |
|
159 |
result.put(GeoJsonConstants.NAME_CRS, createCRS(geometry.getSRID())); |
|
160 |
} |
|
161 |
|
|
162 |
return result; |
|
163 |
} |
|
164 |
|
|
165 |
private Map<String, Object> createCRS(int srid) { |
|
166 |
|
|
167 |
Map<String, Object> result = new LinkedHashMap<String, Object>(); |
|
168 |
result.put(GeoJsonConstants.NAME_TYPE, GeoJsonConstants.NAME_NAME); |
|
169 |
|
|
170 |
Map<String, Object> props = new LinkedHashMap<String, Object>(); |
|
171 |
props.put(GeoJsonConstants.NAME_NAME, EPSG_PREFIX + srid); |
|
172 |
|
|
173 |
result.put(GeoJsonConstants.NAME_PROPERTIES, props); |
|
174 |
|
|
175 |
return result; |
|
176 |
} |
|
177 |
|
|
178 |
private List<JSONAware> makeJsonAware(Polygon poly) { |
|
179 |
ArrayList<JSONAware> result = new ArrayList<JSONAware>(); |
|
180 |
|
|
181 |
{ |
|
182 |
final String jsonString = getJsonString(poly.getExteriorRing() |
|
183 |
.getCoordinateSequence()); |
|
184 |
result.add(new JSONAware() { |
|
185 |
|
|
186 |
public String toJSONString() { |
|
187 |
return jsonString; |
|
188 |
} |
|
189 |
}); |
|
190 |
} |
|
191 |
for (int i = 0; i < poly.getNumInteriorRing(); i++) { |
|
192 |
final String jsonString = getJsonString(poly.getInteriorRingN(i) |
|
193 |
.getCoordinateSequence()); |
|
194 |
result.add(new JSONAware() { |
|
195 |
|
|
196 |
public String toJSONString() { |
|
197 |
return jsonString; |
|
198 |
} |
|
199 |
}); |
|
200 |
} |
|
201 |
|
|
202 |
return result; |
|
203 |
} |
|
204 |
|
|
205 |
private List<Object> makeJsonAware(GeometryCollection geometryCollection) { |
|
206 |
|
|
207 |
ArrayList<Object> list = new ArrayList<Object>( |
|
208 |
geometryCollection.getNumGeometries()); |
|
209 |
for (int i = 0; i < geometryCollection.getNumGeometries(); i++) { |
|
210 |
Geometry geometry = geometryCollection.getGeometryN(i); |
|
211 |
|
|
212 |
if (geometry instanceof Polygon) { |
|
213 |
Polygon polygon = (Polygon) geometry; |
|
214 |
list.add(makeJsonAware(polygon)); |
|
215 |
} |
|
216 |
else if (geometry instanceof LineString) { |
|
217 |
LineString lineString = (LineString) geometry; |
|
218 |
final String jsonString = getJsonString(lineString |
|
219 |
.getCoordinateSequence()); |
|
220 |
list.add(new JSONAware() { |
|
221 |
|
|
222 |
public String toJSONString() { |
|
223 |
return jsonString; |
|
224 |
} |
|
225 |
}); |
|
226 |
} |
|
227 |
else if (geometry instanceof Point) { |
|
228 |
Point point = (Point) geometry; |
|
229 |
final String jsonString = getJsonString(point.getCoordinateSequence()); |
|
230 |
list.add(new JSONAware() { |
|
231 |
|
|
232 |
public String toJSONString() { |
|
233 |
return jsonString; |
|
234 |
} |
|
235 |
}); |
|
236 |
} |
|
237 |
} |
|
238 |
|
|
239 |
return list; |
|
240 |
} |
|
241 |
|
|
242 |
private String getJsonString(CoordinateSequence coordinateSequence) { |
|
243 |
StringBuffer result = new StringBuffer(); |
|
244 |
|
|
245 |
if (coordinateSequence.size() > 1) { |
|
246 |
result.append("["); |
|
247 |
} |
|
248 |
for (int i = 0; i < coordinateSequence.size(); i++) { |
|
249 |
if (i > 0) { |
|
250 |
result.append(","); |
|
251 |
} |
|
252 |
result.append("["); |
|
253 |
result.append(formatOrdinate(coordinateSequence.getOrdinate(i, CoordinateSequence.X))); |
|
254 |
result.append(","); |
|
255 |
result.append(formatOrdinate(coordinateSequence.getOrdinate(i, CoordinateSequence.Y))); |
|
256 |
|
|
257 |
if (coordinateSequence.getDimension() > 2 ) { |
|
258 |
double z = coordinateSequence.getOrdinate(i, CoordinateSequence.Z); |
|
259 |
if (! Double.isNaN(z)) { |
|
260 |
result.append(","); |
|
261 |
result.append(formatOrdinate(z)); |
|
262 |
} |
|
263 |
} |
|
264 |
|
|
265 |
result.append("]"); |
|
266 |
|
|
267 |
} |
|
268 |
|
|
269 |
if (coordinateSequence.size() > 1) { |
|
270 |
result.append("]"); |
|
271 |
} |
|
272 |
|
|
273 |
return result.toString(); |
|
274 |
} |
|
275 |
|
|
276 |
private String formatOrdinate(double x) { |
|
277 |
String result = null; |
|
278 |
|
|
279 |
if (Math.abs(x) >= Math.pow(10, -3) && x < Math.pow(10, 7)) { |
|
280 |
x = Math.floor(x * scale + 0.5) / scale; |
|
281 |
long lx = (long) x; |
|
282 |
if (lx == x) { |
|
283 |
result = Long.toString(lx); |
|
284 |
} else { |
|
285 |
result = Double.toString(x); |
|
286 |
} |
|
287 |
} else { |
|
288 |
result = Double.toString(x); |
|
289 |
} |
|
290 |
|
|
291 |
return result; |
|
292 |
} |
|
293 |
|
|
294 |
} |
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/util/JTSUtils.java | ||
---|---|---|
43 | 43 |
import com.vividsolutions.jts.util.GeometricShapeFactory; |
44 | 44 |
import java.util.ArrayList; |
45 | 45 |
import java.util.List; |
46 |
import org.apache.commons.lang3.StringUtils; |
|
46 | 47 |
import org.cresques.cts.IProjection; |
47 | 48 |
import org.gvsig.fmap.geom.Geometry; |
48 | 49 |
import static org.gvsig.fmap.geom.Geometry.JOIN_STYLE_BEVEL; |
... | ... | |
207 | 208 |
return theFactory; |
208 | 209 |
} |
209 | 210 |
|
210 |
public static LineString createJTSLineString(CoordinateSequence coordinates) { |
|
211 |
return getFactory(coordinates).createLineString(coordinates);
|
|
211 |
public static LineString createJTSLineString(IProjection proj, CoordinateSequence coordinates) {
|
|
212 |
return (LineString) setSRID(proj, getFactory(coordinates).createLineString(coordinates));
|
|
212 | 213 |
} |
213 | 214 |
|
214 |
public static LinearRing createJTSLinearRing(CoordinateSequence coordinates) { |
|
215 |
public static LinearRing createJTSLinearRing(IProjection proj, CoordinateSequence coordinates) {
|
|
215 | 216 |
GeometryFactory fact = getFactory(coordinates); |
216 |
return fact.createLinearRing(CoordinateSequences.ensureValidRing(fact.getCoordinateSequenceFactory(), coordinates));
|
|
217 |
return (LinearRing) setSRID(proj, fact.createLinearRing(CoordinateSequences.ensureValidRing(fact.getCoordinateSequenceFactory(), coordinates)));
|
|
217 | 218 |
} |
218 | 219 |
|
219 |
public static LinearRing createJTSLinearRing(Coordinate[] coordinates) { |
|
220 |
public static LinearRing createJTSLinearRing(IProjection proj, Coordinate[] coordinates) {
|
|
220 | 221 |
GeometryFactory fact = getFactory(coordinates); |
221 | 222 |
CoordinateSequenceFactory coordinateSequenceFactory = fact.getCoordinateSequenceFactory(); |
222 |
return fact.createLinearRing(CoordinateSequences.ensureValidRing(coordinateSequenceFactory, coordinateSequenceFactory.create(coordinates)));
|
|
223 |
return (LinearRing) setSRID(proj, fact.createLinearRing(CoordinateSequences.ensureValidRing(coordinateSequenceFactory, coordinateSequenceFactory.create(coordinates))));
|
|
223 | 224 |
} |
224 | 225 |
|
225 |
public static MultiPoint createJTSMultiPoint(CoordinateSequence coordinates) { |
|
226 |
return getFactory(coordinates).createMultiPoint(coordinates);
|
|
226 |
public static MultiPoint createJTSMultiPoint(IProjection proj, CoordinateSequence coordinates) {
|
|
227 |
return (MultiPoint) setSRID(proj, getFactory(coordinates).createMultiPoint(coordinates));
|
|
227 | 228 |
} |
228 | 229 |
|
229 | 230 |
public static Geometry createGeometry(IProjection proj, com.vividsolutions.jts.geom.Geometry jtsGeom) { |
... | ... | |
481 | 482 |
return triangle.circumcentre(); |
482 | 483 |
} |
483 | 484 |
|
484 |
public static LineString createJTSLineStringFromArcPoints(Point centre, double radius, double startAngle, double endAngle){ |
|
485 |
public static LineString createJTSLineStringFromArcPoints(IProjection proj, Point centre, double radius, double startAngle, double endAngle){
|
|
485 | 486 |
GeometricShapeFactory shapeFactory = new GeometricShapeFactory(); |
486 | 487 |
shapeFactory.setCentre(((PointJTS)centre).getJTSCoordinate()); |
487 | 488 |
shapeFactory.setSize(radius*2); |
488 |
return shapeFactory.createArc(startAngle, endAngle);
|
|
489 |
return (LineString) setSRID(proj, shapeFactory.createArc(startAngle, endAngle));
|
|
489 | 490 |
} |
490 | 491 |
|
491 |
public static MultiLineString createJTSMultiLineString(LineString[] lineStrings) { |
|
492 |
public static MultiLineString createJTSMultiLineString(IProjection proj, LineString[] lineStrings) {
|
|
492 | 493 |
com.vividsolutions.jts.geom.GeometryFactory theFactory = JTSUtils.factory; |
493 | 494 |
if(lineStrings.length>0){ |
494 | 495 |
theFactory = lineStrings[0].getFactory(); |
495 | 496 |
} |
496 |
return theFactory.createMultiLineString(lineStrings);
|
|
497 |
return (MultiLineString) setSRID(proj, theFactory.createMultiLineString(lineStrings));
|
|
497 | 498 |
} |
498 | 499 |
|
499 | 500 |
/** |
... | ... | |
501 | 502 |
* @param interiorRings |
502 | 503 |
* @return |
503 | 504 |
*/ |
504 |
public static com.vividsolutions.jts.geom.Polygon createJTSPolygon(ArrayListCoordinateSequence coordinates, |
|
505 |
public static com.vividsolutions.jts.geom.Polygon createJTSPolygon(IProjection proj, ArrayListCoordinateSequence coordinates,
|
|
505 | 506 |
List<Ring> interiorRings) { |
506 | 507 |
com.vividsolutions.jts.geom.GeometryFactory theFactory = getFactory(coordinates); |
507 | 508 |
|
... | ... | |
511 | 512 |
Ring ring = interiorRings.get(i); |
512 | 513 |
holes[i] = (LinearRing) ((GeometryJTS) ring).getJTS(); |
513 | 514 |
} |
514 |
return theFactory.createPolygon(shell, holes);
|
|
515 |
return (com.vividsolutions.jts.geom.Polygon) setSRID(proj, theFactory.createPolygon(shell, holes));
|
|
515 | 516 |
} |
516 | 517 |
|
517 | 518 |
|
... | ... | |
519 | 520 |
* @param coordinates |
520 | 521 |
* @return |
521 | 522 |
*/ |
522 |
public static com.vividsolutions.jts.geom.Polygon createJTSPolygon(ArrayListCoordinateSequence coordinates) { |
|
523 |
public static com.vividsolutions.jts.geom.Polygon createJTSPolygon(IProjection proj, ArrayListCoordinateSequence coordinates) {
|
|
523 | 524 |
com.vividsolutions.jts.geom.GeometryFactory theFactory = getFactory(coordinates); |
524 | 525 |
|
525 | 526 |
LinearRing shell = theFactory.createLinearRing(coordinates); |
526 |
return theFactory.createPolygon(shell);
|
|
527 |
return (com.vividsolutions.jts.geom.Polygon) setSRID(proj, theFactory.createPolygon(shell));
|
|
527 | 528 |
} |
528 | 529 |
|
529 |
public static com.vividsolutions.jts.geom.MultiPolygon createJTSMultiPolygon(com.vividsolutions.jts.geom.Polygon[] polygons){ |
|
530 |
public static com.vividsolutions.jts.geom.MultiPolygon createJTSMultiPolygon(IProjection proj, com.vividsolutions.jts.geom.Polygon[] polygons){
|
|
530 | 531 |
com.vividsolutions.jts.geom.GeometryFactory theFactory = JTSUtils.factory; |
531 | 532 |
if(polygons.length>0){ |
532 | 533 |
theFactory = polygons[0].getFactory(); |
533 | 534 |
} |
534 |
return theFactory.createMultiPolygon(polygons); |
|
535 |
MultiPolygon g = theFactory.createMultiPolygon(polygons); |
|
536 |
setSRID(proj, g); |
|
537 |
return g; |
|
535 | 538 |
} |
539 |
|
|
540 |
public static com.vividsolutions.jts.geom.Geometry setSRID(IProjection proj, com.vividsolutions.jts.geom.Geometry g) { |
|
541 |
try { |
|
542 |
String x = StringUtils.split(proj.getAbrev(), ':')[1]; |
|
543 |
g.setSRID(Integer.valueOf(x)); |
|
544 |
} catch (Exception ex) { |
|
545 |
//Do nothing |
|
546 |
} |
|
547 |
return g; |
|
548 |
|
|
549 |
} |
|
536 | 550 |
|
537 | 551 |
/** |
538 | 552 |
* Returns the intersection point between an ellipse and her minor axis. |
... | ... | |
581 | 595 |
* @param coordinate |
582 | 596 |
* @return |
583 | 597 |
*/ |
584 |
public static com.vividsolutions.jts.geom.Geometry createJTSPoint(Coordinate coordinate) { |
|
585 |
return getFactory(coordinate).createPoint(coordinate);
|
|
598 |
public static com.vividsolutions.jts.geom.Geometry createJTSPoint(IProjection proj, Coordinate coordinate) {
|
|
599 |
return setSRID(proj, getFactory(coordinate).createPoint(coordinate));
|
|
586 | 600 |
} |
587 | 601 |
|
588 | 602 |
/** |
589 | 603 |
* @param coordinates |
590 | 604 |
* @return |
591 | 605 |
*/ |
592 |
public static com.vividsolutions.jts.geom.Geometry createJTSPolygon(Coordinate[] coordinates) { |
|
593 |
return getFactory(coordinates).createPolygon(coordinates);
|
|
606 |
public static com.vividsolutions.jts.geom.Geometry createJTSPolygon(IProjection proj, Coordinate[] coordinates) {
|
|
607 |
return setSRID(proj, getFactory(coordinates).createPolygon(coordinates));
|
|
594 | 608 |
} |
595 | 609 |
|
596 | 610 |
public static BufferParameters getBufferParameters(){ |
... | ... | |
637 | 651 |
* @return |
638 | 652 |
*/ |
639 | 653 |
public static Geometry offsetClosedLine(IProjection proj, ArrayListCoordinateSequence coordinates, double distance) { |
640 |
com.vividsolutions.jts.geom.Geometry jtsGeom = JTSUtils.createJTSPolygon(coordinates); |
|
654 |
com.vividsolutions.jts.geom.Geometry jtsGeom = JTSUtils.createJTSPolygon(proj, coordinates);
|
|
641 | 655 |
com.vividsolutions.jts.geom.Geometry geomJTS = jtsGeom.buffer(distance); |
642 | 656 |
return jtsPolygonToJtsMultiLineString(geomJTS, proj); |
643 | 657 |
} |
... | ... | |
652 | 666 |
* @return |
653 | 667 |
*/ |
654 | 668 |
public static Geometry offsetClosedLine(IProjection proj, ArrayListCoordinateSequence coordinates, int joinStyle, double distance) { |
655 |
com.vividsolutions.jts.geom.Geometry jtsGeom = JTSUtils.createJTSPolygon(coordinates); |
|
669 |
com.vividsolutions.jts.geom.Geometry jtsGeom = JTSUtils.createJTSPolygon(proj, coordinates);
|
|
656 | 670 |
com.vividsolutions.jts.geom.Geometry geomJTS = jtsGeom.buffer(distance, calculateQuadrantSegments(joinStyle), BufferParameters.CAP_FLAT); |
657 | 671 |
return jtsPolygonToJtsMultiLineString(geomJTS, proj); |
658 | 672 |
} |
... | ... | |
669 | 683 |
LineString hole = polygonJTS.getInteriorRingN(i); |
670 | 684 |
lineStrings[i + 1] = hole; |
671 | 685 |
} |
672 |
return JTSUtils.createGeometry(proj, JTSUtils.createJTSMultiLineString(lineStrings)); |
|
686 |
return JTSUtils.createGeometry(proj, JTSUtils.createJTSMultiLineString(proj, lineStrings));
|
|
673 | 687 |
} |
674 | 688 |
return JTSUtils.createGeometry(proj, shell); |
675 | 689 |
} else if (geomJTS instanceof com.vividsolutions.jts.geom.MultiPolygon) { |
... | ... | |
687 | 701 |
} |
688 | 702 |
} |
689 | 703 |
} |
690 |
return JTSUtils.createGeometry(proj, JTSUtils.createJTSMultiLineString(lineStringList.toArray(new LineString[lineStringList.size()]))); |
|
704 |
return JTSUtils.createGeometry(proj, JTSUtils.createJTSMultiLineString(proj, lineStringList.toArray(new LineString[lineStringList.size()])));
|
|
691 | 705 |
} |
692 | 706 |
//No deber?a pasar por aqu? |
693 | 707 |
logger.warn("offsetClosedLine does not return or Polygon JTS or MultiPolygon JTS"); |
... | ... | |
705 | 719 |
com.vividsolutions.jts.geom.GeometryFactory theFactory = getFactory(coordinates); |
706 | 720 |
|
707 | 721 |
BufferParameters bufParams = JTSUtils.getBufferParameters(); |
708 |
LineString jtsGeom = JTSUtils.createJTSLineString(coordinates); |
|
722 |
LineString jtsGeom = JTSUtils.createJTSLineString(proj, coordinates);
|
|
709 | 723 |
|
710 | 724 |
OffsetCurveBuilder ocb = new |
711 | 725 |
OffsetCurveBuilder(theFactory.getPrecisionModel(), bufParams); |
712 | 726 |
Coordinate[] coords = ocb.getOffsetCurve(jtsGeom.getCoordinates(), distance); |
713 | 727 |
CoordinateSequence coordSequence = theFactory.getCoordinateSequenceFactory().create(coords); |
714 |
com.vividsolutions.jts.geom.Geometry offsetGeom = JTSUtils.createJTSLineString(coordSequence); |
|
728 |
com.vividsolutions.jts.geom.Geometry offsetGeom = JTSUtils.createJTSLineString(proj, coordSequence);
|
|
715 | 729 |
|
716 | 730 |
return JTSUtils.createGeometry(proj, offsetGeom); |
717 | 731 |
} |
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/util/OpenJUMPUtils.java | ||
---|---|---|
53 | 53 |
public static Geometry offsetCleanOpenLine(IProjection proj, ArrayListCoordinateSequence coordinates, double distance) { |
54 | 54 |
com.vividsolutions.jts.geom.GeometryFactory factory = JTSUtils.getFactory(coordinates); |
55 | 55 |
|
56 |
LineString jtsGeom = JTSUtils.createJTSLineString(coordinates); |
|
56 |
LineString jtsGeom = JTSUtils.createJTSLineString(proj, coordinates);
|
|
57 | 57 |
|
58 | 58 |
BufferParameters bufParams = JTSUtils.getBufferParameters(); |
59 | 59 |
|
... | ... | |
120 | 120 |
public static Geometry offsetCleanOpenLine(IProjection proj, ArrayListCoordinateSequence coordinates, BufferParameters bufParams, double distance) { |
121 | 121 |
com.vividsolutions.jts.geom.GeometryFactory factory = JTSUtils.getFactory(coordinates); |
122 | 122 |
|
123 |
LineString jtsGeom = JTSUtils.createJTSLineString(coordinates); |
|
123 |
LineString jtsGeom = JTSUtils.createJTSLineString(proj, coordinates);
|
|
124 | 124 |
|
125 | 125 |
// BufferParameters bufParams = JTSUtils.getBufferParameters(); |
126 | 126 |
|
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/gml/GeometryStrategies.java | ||
---|---|---|
162 | 162 |
// coord set |
163 | 163 |
try{ |
164 | 164 |
CoordinateSequence cs = (CoordinateSequence) arg.children.get(0); |
165 |
ls = JTSUtils.createJTSLinearRing(cs); |
|
165 |
ls = JTSUtils.createJTSLinearRing(null, cs);
|
|
166 | 166 |
}catch(Exception e){ |
167 | 167 |
throw new SAXException("Cannot create a linear ring without atleast four coordinates or one coordinate sequence",e); |
168 | 168 |
} |
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/gml/GeometryStrategiesGML3.java | ||
---|---|---|
250 | 250 |
merger.add(segment); |
251 | 251 |
} |
252 | 252 |
List<LineString> merged = (List<LineString>) merger.getMergedLineStrings(); |
253 |
return JTSUtils.createJTSLinearRing(merged.get(0).getCoordinateSequence()); |
|
253 |
return JTSUtils.createJTSLinearRing(null, merged.get(0).getCoordinateSequence());
|
|
254 | 254 |
|
255 | 255 |
} |
256 | 256 |
}); |
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/aggregate/AbstractMultiLine.java | ||
---|---|---|
57 | 57 |
for(int i=0; i<primitives.size(); i++){ |
58 | 58 |
lineStrings[i]=(LineString) ((GeometryJTS)primitives.get(i)).getJTS(); |
59 | 59 |
} |
60 |
return JTSUtils.createJTSMultiLineString(lineStrings); |
|
60 |
return JTSUtils.createJTSMultiLineString(getProjection(), lineStrings);
|
|
61 | 61 |
} |
62 | 62 |
|
63 | 63 |
@Override |
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/aggregate/AbstractMultiPolygon.java | ||
---|---|---|
67 | 67 |
for (int i=0; i<primitives.size(); i++){ |
68 | 68 |
polygons[i] = (com.vividsolutions.jts.geom.Polygon) ((GeometryJTS)primitives.get(i)).getJTS(); |
69 | 69 |
} |
70 |
return JTSUtils.createJTSMultiPolygon(polygons); |
|
70 |
return JTSUtils.createJTSMultiPolygon(getProjection(), polygons);
|
|
71 | 71 |
} |
72 | 72 |
|
73 | 73 |
@Override |
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/aggregate/AbstractMultiPoint.java | ||
---|---|---|
66 | 66 |
PointJTS point = (PointJTS) iterator.next(); |
67 | 67 |
coordinateSequence.add(point.getJTSCoordinate()); |
68 | 68 |
} |
69 |
return JTSUtils.createJTSMultiPoint(coordinateSequence); |
|
69 |
return JTSUtils.createJTSMultiPoint(getProjection(), coordinateSequence);
|
|
70 | 70 |
} |
71 | 71 |
|
72 | 72 |
|
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/aggregate/DefaultMultiCurve.java | ||
---|---|---|
230 | 230 |
} |
231 | 231 |
} |
232 | 232 |
} |
233 |
return JTSUtils.createJTSMultiLineString(lineStrings.toArray(new LineString[lineStrings.size()])); |
|
233 |
return JTSUtils.createJTSMultiLineString(getProjection(), lineStrings.toArray(new LineString[lineStrings.size()]));
|
|
234 | 234 |
} |
235 | 235 |
|
236 | 236 |
@Override |
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/aggregate/DefaultMultiSurface.java | ||
---|---|---|
235 | 235 |
} |
236 | 236 |
} |
237 | 237 |
return JTSUtils |
238 |
.createJTSMultiPolygon(polygons.toArray(new com.vividsolutions.jts.geom.Polygon[polygons.size()])); |
|
238 |
.createJTSMultiPolygon(getProjection(), polygons.toArray(new com.vividsolutions.jts.geom.Polygon[polygons.size()]));
|
|
239 | 239 |
} |
240 | 240 |
|
241 | 241 |
@Override |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/Geometry.java | ||
---|---|---|
28 | 28 |
import java.awt.geom.PathIterator; |
29 | 29 |
import java.awt.geom.Rectangle2D; |
30 | 30 |
import java.io.Serializable; |
31 |
import java.util.Map; |
|
31 | 32 |
|
32 | 33 |
import org.cresques.cts.ICoordTrans; |
33 | 34 |
import org.cresques.cts.IProjection; |
... | ... | |
502 | 503 |
*/ |
503 | 504 |
public GeometryType getGeometryType(); |
504 | 505 |
|
505 |
public Object convertTo(String format) throws GeometryOperationNotSupportedException, |
|
506 |
public Object convertTo(String format, Object...args) throws GeometryOperationNotSupportedException,
|
|
506 | 507 |
GeometryOperationException; |
507 | 508 |
|
509 |
public String convertToGeoJson(Map<String,Object>properties, boolean encodecrs) |
|
510 |
throws GeometryOperationNotSupportedException, GeometryOperationException; |
|
511 |
|
|
508 | 512 |
/** |
509 | 513 |
* Return a byte array with the equivalent in WKB format of the Geometry. |
510 | 514 |
* |
Also available in: Unified diff