|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
|
2 |
*
|
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
|
4 |
*
|
|
5 |
* This program is free software; you can redistribute it and/or
|
|
6 |
* modify it under the terms of the GNU General Public License
|
|
7 |
* as published by the Free Software Foundation; either version 2
|
|
8 |
* of the License, or (at your option) any later version.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
|
18 |
*/
|
|
19 |
|
1 |
20 |
package org.gvsig.fmap.dal.store.gpe.handlers;
|
2 |
21 |
|
3 |
22 |
import java.io.File;
|
... | ... | |
26 |
45 |
import org.gvsig.fmap.geom.GeometryLocator;
|
27 |
46 |
import org.gvsig.fmap.geom.GeometryManager;
|
28 |
47 |
import org.gvsig.fmap.geom.aggregate.MultiCurve;
|
|
48 |
import org.gvsig.fmap.geom.aggregate.MultiLine;
|
29 |
49 |
import org.gvsig.fmap.geom.aggregate.MultiPoint;
|
30 |
|
import org.gvsig.fmap.geom.aggregate.MultiPrimitive;
|
31 |
|
import org.gvsig.fmap.geom.aggregate.MultiSurface;
|
|
50 |
import org.gvsig.fmap.geom.aggregate.MultiPolygon;
|
32 |
51 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
|
33 |
52 |
import org.gvsig.fmap.geom.exception.CreateGeometryException;
|
34 |
53 |
import org.gvsig.fmap.geom.primitive.Curve;
|
35 |
54 |
import org.gvsig.fmap.geom.primitive.Envelope;
|
36 |
|
import org.gvsig.fmap.geom.primitive.GeneralPathX;
|
|
55 |
import org.gvsig.fmap.geom.primitive.Line;
|
37 |
56 |
import org.gvsig.fmap.geom.primitive.Point;
|
38 |
|
import org.gvsig.fmap.geom.primitive.Primitive;
|
39 |
|
import org.gvsig.fmap.geom.primitive.Surface;
|
|
57 |
import org.gvsig.fmap.geom.primitive.Polygon;
|
|
58 |
import org.gvsig.fmap.geom.primitive.Ring;
|
40 |
59 |
import org.gvsig.gpe.lib.api.parser.IAttributesIterator;
|
41 |
60 |
import org.gvsig.gpe.lib.api.parser.ICoordinateIterator;
|
42 |
61 |
import org.gvsig.gpe.lib.api.parser.IGPEErrorHandler;
|
... | ... | |
44 |
63 |
import org.jfree.util.Log;
|
45 |
64 |
import org.slf4j.Logger;
|
46 |
65 |
import org.slf4j.LoggerFactory;
|
47 |
|
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
48 |
|
*
|
49 |
|
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
50 |
|
*
|
51 |
|
* This program is free software; you can redistribute it and/or
|
52 |
|
* modify it under the terms of the GNU General Public License
|
53 |
|
* as published by the Free Software Foundation; either version 2
|
54 |
|
* of the License, or (at your option) any later version.
|
55 |
|
*
|
56 |
|
* This program is distributed in the hope that it will be useful,
|
57 |
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
58 |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
59 |
|
* GNU General Public License for more details.
|
60 |
|
*
|
61 |
|
* You should have received a copy of the GNU General Public License
|
62 |
|
* along with this program; if not, write to the Free Software
|
63 |
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
64 |
|
*/
|
65 |
66 |
|
|
67 |
|
|
68 |
|
66 |
69 |
public class FmapContentHandler extends GPEContentHandler {
|
67 |
70 |
private static final Logger LOG = LoggerFactory.getLogger(FmapContentHandler.class);
|
68 |
71 |
|
... | ... | |
87 |
90 |
this.file = file;
|
88 |
91 |
this.srs = srs;
|
89 |
92 |
this.geometryType = geometryType;
|
90 |
|
}
|
91 |
|
|
|
93 |
}
|
|
94 |
|
92 |
95 |
public FmapContentHandler(IGPEErrorHandler errorHandler, FeatureStoreProviderServices store,
|
93 |
96 |
GPEStoreProvider storeProvider, File file, IProjection srs, int geometryType,
|
94 |
97 |
boolean useAxisOrderYX) {
|
... | ... | |
228 |
231 |
return createCurve(coords);
|
229 |
232 |
}
|
230 |
233 |
|
231 |
|
private Curve createCurve(ICoordinateIterator coords){
|
232 |
|
GeneralPathX gp = createGeneralPathX(coords);
|
|
234 |
private Line createCurve(ICoordinateIterator coords){
|
|
235 |
// GeneralPathX gp = createGeneralPathX(coords);
|
233 |
236 |
try {
|
234 |
|
Curve curve = null;
|
|
237 |
Line curve = null;
|
235 |
238 |
if (coords == null || coords.getDimension() == 2){
|
236 |
|
curve = (Curve) geomManager.create(TYPES.CURVE, SUBTYPES.GEOM2D);
|
|
239 |
curve = (Line) geomManager.create(TYPES.LINE, SUBTYPES.GEOM2D);
|
237 |
240 |
}else if (coords.getDimension() == 3){
|
238 |
|
curve = (Curve) geomManager.create(TYPES.CURVE, SUBTYPES.GEOM3D);
|
|
241 |
curve = (Line) geomManager.create(TYPES.LINE, SUBTYPES.GEOM3D);
|
239 |
242 |
}
|
240 |
|
curve.setGeneralPath(gp);
|
|
243 |
while (coords.hasNext()){
|
|
244 |
Point point=createPoint(coords);
|
|
245 |
curve.addVertex(point);
|
|
246 |
}
|
|
247 |
// curve.setGeneralPath(gp);
|
241 |
248 |
return curve;
|
242 |
249 |
} catch (CreateGeometryException e) {
|
243 |
250 |
getErrorHandler().addError(e);
|
244 |
|
}
|
245 |
|
return null;
|
246 |
|
}
|
247 |
|
|
248 |
|
private GeneralPathX createGeneralPathX(ICoordinateIterator coords){
|
249 |
|
GeneralPathX gp = new GeneralPathX();
|
250 |
|
if (coords == null){
|
251 |
|
return gp;
|
252 |
|
}
|
253 |
|
double[] buffer = new double[coords.getDimension()];
|
254 |
|
try {
|
255 |
|
if (coords.hasNext()){
|
256 |
|
coords.next(buffer);
|
257 |
|
if( this.useAxisOrderYX ) {
|
258 |
|
gp.moveTo(buffer[1], buffer[0]);
|
259 |
|
} else {
|
260 |
|
gp.moveTo(buffer[0], buffer[1]);
|
261 |
|
}
|
262 |
|
}
|
263 |
|
while(coords.hasNext()){
|
264 |
|
coords.next(buffer);
|
265 |
|
if( this.useAxisOrderYX ) {
|
266 |
|
gp.lineTo(buffer[1], buffer[0]);
|
267 |
|
} else {
|
268 |
|
gp.lineTo(buffer[0], buffer[1]);
|
269 |
|
}
|
270 |
|
}
|
271 |
251 |
} catch (IOException e) {
|
272 |
252 |
getErrorHandler().addError(e);
|
273 |
253 |
}
|
274 |
|
return gp;
|
|
254 |
return null;
|
275 |
255 |
}
|
276 |
256 |
|
|
257 |
// private GeneralPathX createGeneralPathX(ICoordinateIterator coords){
|
|
258 |
// GeneralPathX gp = new GeneralPathX();
|
|
259 |
// if (coords == null){
|
|
260 |
// return gp;
|
|
261 |
// }
|
|
262 |
// double[] buffer = new double[coords.getDimension()];
|
|
263 |
// try {
|
|
264 |
// if (coords.hasNext()){
|
|
265 |
// coords.next(buffer);
|
|
266 |
// if( this.useAxisOrderYX ) {
|
|
267 |
// gp.moveTo(buffer[1], buffer[0]);
|
|
268 |
// } else {
|
|
269 |
// gp.moveTo(buffer[0], buffer[1]);
|
|
270 |
// }
|
|
271 |
// }
|
|
272 |
// while(coords.hasNext()){
|
|
273 |
// coords.next(buffer);
|
|
274 |
// if( this.useAxisOrderYX ) {
|
|
275 |
// gp.lineTo(buffer[1], buffer[0]);
|
|
276 |
// } else {
|
|
277 |
// gp.lineTo(buffer[0], buffer[1]);
|
|
278 |
// }
|
|
279 |
// }
|
|
280 |
// } catch (IOException e) {
|
|
281 |
// getErrorHandler().addError(e);
|
|
282 |
// }
|
|
283 |
// return gp;
|
|
284 |
// }
|
|
285 |
|
277 |
286 |
/* (non-Javadoc)
|
278 |
287 |
* @see org.gvsig.gpe.parser.GPEContentHandler#startPolygon(java.lang.String, org.gvsig.gpe.parser.ICoordinateIterator, java.lang.String)
|
279 |
288 |
*/
|
280 |
289 |
|
281 |
290 |
public Object startPolygon(String id, ICoordinateIterator coords, String srs) {
|
282 |
|
return createSurface(coords);
|
|
291 |
return createPolygon(coords);
|
283 |
292 |
}
|
284 |
293 |
|
285 |
|
private Surface createSurface(ICoordinateIterator coords){
|
286 |
|
GeneralPathX gp = createGeneralPathX(coords);
|
|
294 |
private Polygon createPolygon(ICoordinateIterator coords){
|
|
295 |
// GeneralPathX gp = createGeneralPathX(coords);
|
287 |
296 |
try {
|
288 |
|
Surface surface = null;
|
|
297 |
Polygon polygon = null;
|
289 |
298 |
if (coords.getDimension() == 2){
|
290 |
|
surface = (Surface) geomManager.create(TYPES.SURFACE, SUBTYPES.GEOM2D);
|
|
299 |
polygon = (Polygon) geomManager.create(TYPES.POLYGON, SUBTYPES.GEOM2D);
|
291 |
300 |
}else if (coords.getDimension() == 3){
|
292 |
|
surface = (Surface) geomManager.create(TYPES.SURFACE, SUBTYPES.GEOM3D);
|
|
301 |
polygon = (Polygon) geomManager.create(TYPES.POLYGON, SUBTYPES.GEOM3D);
|
293 |
302 |
}
|
294 |
|
surface.setGeneralPath(gp);
|
295 |
|
return surface;
|
|
303 |
//surface.setGeneralPath(gp);
|
|
304 |
while (coords.hasNext()){
|
|
305 |
Point point=createPoint(coords);
|
|
306 |
polygon.addVertex(point);
|
|
307 |
}
|
|
308 |
if (!polygon.getVertex(0).equals(polygon.getVertex(polygon.getNumVertices()-1))){
|
|
309 |
polygon.addVertex(polygon.getVertex(0));
|
|
310 |
}
|
|
311 |
|
|
312 |
return polygon;
|
296 |
313 |
} catch (CreateGeometryException e) {
|
297 |
314 |
getErrorHandler().addError(e);
|
|
315 |
} catch (IOException e) {
|
|
316 |
getErrorHandler().addError(e);
|
298 |
317 |
}
|
299 |
318 |
return null;
|
300 |
319 |
}
|
... | ... | |
305 |
324 |
*/
|
306 |
325 |
public Object startInnerPolygon(String id, ICoordinateIterator coords,
|
307 |
326 |
String srs) {
|
308 |
|
return createSurface(coords);
|
|
327 |
return createPolygon(coords);
|
309 |
328 |
}
|
310 |
329 |
|
311 |
330 |
/*
|
... | ... | |
313 |
332 |
* @see org.gvsig.gpe.IGPEContentHandler#addGeometryToFeature(java.lang.Object, java.lang.Object)
|
314 |
333 |
*/
|
315 |
334 |
public void addGeometryToFeature(Object geometry, Object feature) {
|
316 |
|
|
|
335 |
|
317 |
336 |
/*
|
318 |
337 |
* Two geometries (possibly of different type) in the same feature
|
319 |
338 |
* Instead of overwriting we will preserve the first that arrives.
|
320 |
339 |
* Alternative: aggregate, but then gvSIG would have issues to
|
321 |
|
* draw? or export?
|
|
340 |
* draw? or export?
|
322 |
341 |
*/
|
323 |
342 |
GPEFeature gpe_feat = (GPEFeature) feature;
|
324 |
343 |
Geometry geom = gpe_feat.getGeometry();
|
325 |
344 |
if (geom == null ||
|
326 |
345 |
geom.getGeometryType().getType() == Geometry.TYPES.NULL) {
|
327 |
|
|
|
346 |
|
328 |
347 |
gpe_feat.setGeometry((Geometry)geometry);
|
329 |
348 |
}
|
330 |
349 |
}
|
... | ... | |
389 |
408 |
FeatureProvider data = new DefaultFeatureProvider(featureType.getNotEditableCopy(), storeProvider.createNewOID());
|
390 |
409 |
Map elements = gpefeature.getelements();
|
391 |
410 |
Iterator keys = elements.keySet().iterator();
|
392 |
|
String gid = gpefeature.getId();
|
393 |
|
data.setOID(gid);
|
|
411 |
String gid = gpefeature.getId();
|
|
412 |
data.setOID(gid);
|
394 |
413 |
while (keys.hasNext()){
|
395 |
414 |
String elementName = (String)keys.next();
|
396 |
415 |
if (featureType.getIndex(elementName) != -1) {
|
... | ... | |
398 |
417 |
* If attribute exists, set its value
|
399 |
418 |
* (if a field description was not properly parsed in the
|
400 |
419 |
* feature type description (previous http request) then
|
401 |
|
* perhaps it's not available in featureType)
|
|
420 |
* perhaps it's not available in featureType)
|
402 |
421 |
*/
|
403 |
422 |
data.set(elementName, ((GPEElement)elements.get(elementName)).getValue());
|
404 |
423 |
}
|
... | ... | |
411 |
430 |
|
412 |
431 |
private void createFeatureType(GPEFeature gpefeature){
|
413 |
432 |
featureType = store.createFeatureType();
|
414 |
|
|
|
433 |
|
415 |
434 |
//Adding the Geometry field
|
416 |
435 |
EditableFeatureAttributeDescriptor attributeDescriptor = featureType.add("the_geom", DataTypes.GEOMETRY).setGeometryType(geometryType);
|
417 |
436 |
attributeDescriptor.setGeometrySubType(SUBTYPES.GEOM2D);
|
418 |
437 |
attributeDescriptor.setSRS(srs);
|
419 |
438 |
featureType.setDefaultGeometryAttributeName("the_geom");
|
420 |
|
|
|
439 |
|
421 |
440 |
//Adding the ID
|
422 |
441 |
EditableFeatureAttributeDescriptor ed = featureType.add("gid", DataTypes.LONG);
|
423 |
442 |
ed.setSize(10);
|
... | ... | |
521 |
540 |
IAttributesIterator attributes, Object layer){
|
522 |
541 |
String sId;
|
523 |
542 |
if (id == null){
|
524 |
|
sId = new String(new Long(featureId).toString());
|
|
543 |
sId = new String(new Long(featureId).toString());
|
525 |
544 |
}else{
|
526 |
545 |
sId = id;
|
527 |
546 |
}
|
... | ... | |
567 |
586 |
*/
|
568 |
587 |
public Object startLinearRing(String id, ICoordinateIterator coords,
|
569 |
588 |
String srs) {
|
570 |
|
return createSurface(coords);
|
|
589 |
return createPolygon(coords);
|
571 |
590 |
}
|
572 |
591 |
|
573 |
592 |
/*
|
... | ... | |
585 |
604 |
|
586 |
605 |
/*
|
587 |
606 |
* (non-Javadoc)
|
|
607 |
* @see org.gvsig.gpe.IGPEContentHandler#startMultiPoint(java.lang.String, java.lang.String)
|
|
608 |
*/
|
|
609 |
public Object startMultiPoint(String id, String srs) {
|
|
610 |
try {
|
|
611 |
return geomManager.create(TYPES.MULTIPOINT, Geometry.SUBTYPES.GEOM2D);
|
|
612 |
} catch (CreateGeometryException e) {
|
|
613 |
getErrorHandler().addError(e);
|
|
614 |
}
|
|
615 |
return null;
|
|
616 |
}
|
|
617 |
|
|
618 |
/*
|
|
619 |
* (non-Javadoc)
|
588 |
620 |
* @see org.gvsig.gpe.IGPEContentHandler#addPointToMultiPoint(java.lang.Object, java.lang.Object)
|
589 |
621 |
*/
|
590 |
622 |
public void addPointToMultiPoint(Object point, Object multiPoint) {
|
591 |
|
((MultiPoint)multiPoint).addPoint((Point)point);
|
|
623 |
if (point instanceof Point){
|
|
624 |
Point gPoint=(Point)point;
|
|
625 |
if (gPoint.getGeometryType().isSubTypeOf( Geometry.SUBTYPES.GEOM3D)){
|
|
626 |
try {
|
|
627 |
Point point2D=(Point)geomManager.create(TYPES.POINT, Geometry.SUBTYPES.GEOM2D);
|
|
628 |
point2D.setX(gPoint.getX());
|
|
629 |
point2D.setY(gPoint.getY());
|
|
630 |
((MultiPoint)multiPoint).addPoint(point2D);
|
|
631 |
} catch (CreateGeometryException e) {
|
|
632 |
getErrorHandler().addError(e);
|
|
633 |
}
|
|
634 |
}else{
|
|
635 |
((MultiPoint)multiPoint).addPoint((Point)point);
|
|
636 |
}
|
|
637 |
}
|
592 |
638 |
}
|
593 |
639 |
|
594 |
640 |
/*
|
... | ... | |
598 |
644 |
public Object startMultiLineString(String id, String srs, int dimension) {
|
599 |
645 |
super.startMultiLineString(id, srs);
|
600 |
646 |
try {
|
601 |
|
return geomManager.create(TYPES.MULTICURVE, getGeometrySubtype(dimension));
|
|
647 |
return geomManager.create(TYPES.MULTILINE, getGeometrySubtype(dimension));
|
602 |
648 |
} catch (CreateGeometryException e) {
|
603 |
649 |
getErrorHandler().addError(e);
|
604 |
650 |
}
|
... | ... | |
607 |
653 |
|
608 |
654 |
/*
|
609 |
655 |
* (non-Javadoc)
|
|
656 |
* @see org.gvsig.gpe.IGPEContentHandler#startMultiLineString(java.lang.String, java.lang.String)
|
|
657 |
*/
|
|
658 |
public Object startMultiLineString(String id, String srs) {
|
|
659 |
return startMultiLineString (id, srs, Geometry.SUBTYPES.GEOM2D);
|
|
660 |
}
|
|
661 |
|
|
662 |
/*
|
|
663 |
* (non-Javadoc)
|
610 |
664 |
* @see org.gvsig.gpe.IGPEContentHandler#addLineStringToMultiLineString(java.lang.Object, java.lang.Object)
|
611 |
665 |
*/
|
612 |
666 |
public void addLineStringToMultiLineString(Object lineString, Object multiLineString) {
|
613 |
|
((MultiCurve)multiLineString).addCurve((Curve)lineString);
|
|
667 |
if (lineString instanceof Line){
|
|
668 |
Line gLine=(Line)lineString;
|
|
669 |
if (gLine.getGeometryType().isSubTypeOf( Geometry.SUBTYPES.GEOM3D)){
|
|
670 |
try {
|
|
671 |
Line line2D=(Line)geomManager.create(TYPES.LINE, Geometry.SUBTYPES.GEOM2D);
|
|
672 |
for(int i=0;i<gLine.getNumVertices();i++){
|
|
673 |
Point point2D=(Point)geomManager.create(TYPES.POINT, Geometry.SUBTYPES.GEOM2D);
|
|
674 |
Point point3D=gLine.getVertex(i);
|
|
675 |
point2D.setX(point3D.getX());
|
|
676 |
point2D.setY(point3D.getY());
|
|
677 |
line2D.addVertex(point2D);
|
|
678 |
}
|
|
679 |
((MultiLine)multiLineString).addPrimitive(line2D);;
|
|
680 |
} catch (CreateGeometryException e) {
|
|
681 |
getErrorHandler().addError(e);
|
|
682 |
}
|
|
683 |
}else{
|
|
684 |
((MultiLine)multiLineString).addPrimitive((Line)lineString);
|
|
685 |
}
|
|
686 |
}
|
614 |
687 |
}
|
615 |
688 |
|
616 |
689 |
/*
|
... | ... | |
620 |
693 |
public Object startMultiPolygon(String id, String srs, int dimension) {
|
621 |
694 |
super.startMultiPolygon(id, srs);
|
622 |
695 |
try {
|
623 |
|
return geomManager.create(TYPES.MULTISURFACE, getGeometrySubtype(dimension));
|
|
696 |
return geomManager.create(TYPES.MULTIPOLYGON, getGeometrySubtype(dimension));
|
624 |
697 |
} catch (CreateGeometryException e) {
|
625 |
698 |
getErrorHandler().addError(e);
|
626 |
699 |
}
|
... | ... | |
629 |
702 |
|
630 |
703 |
/*
|
631 |
704 |
* (non-Javadoc)
|
|
705 |
* @see org.gvsig.gpe.IGPEContentHandler#startMultiPolygon(java.lang.String, java.lang.String)
|
|
706 |
*/
|
|
707 |
public Object startMultiPolygon(String id, String srs) {
|
|
708 |
return startMultiPolygon(id, srs, Geometry.SUBTYPES.GEOM2D);
|
|
709 |
}
|
|
710 |
|
|
711 |
/*
|
|
712 |
* (non-Javadoc)
|
632 |
713 |
* @see org.gvsig.gpe.IGPEContentHandler#addPolygonToMultiPolygon(java.lang.Object, java.lang.Object)
|
633 |
714 |
*/
|
634 |
715 |
public void addPolygonToMultiPolygon(Object polygon, Object multiPolygon) {
|
635 |
|
((MultiSurface)multiPolygon).addSurface((Surface)polygon);
|
|
716 |
if (polygon instanceof Polygon){
|
|
717 |
Polygon gPolygon=(Polygon)polygon;
|
|
718 |
if (gPolygon.getGeometryType().isSubTypeOf( Geometry.SUBTYPES.GEOM3D)){
|
|
719 |
try {
|
|
720 |
Polygon polygon2D=(Polygon)geomManager.create(TYPES.POLYGON, Geometry.SUBTYPES.GEOM2D);
|
|
721 |
for (int p=0;p<gPolygon.getNumVertices();p++){
|
|
722 |
Point point2D=(Point)geomManager.create(TYPES.POINT, Geometry.SUBTYPES.GEOM2D);
|
|
723 |
Point point3D=gPolygon.getVertex(p);
|
|
724 |
point2D.setX(point3D.getX());
|
|
725 |
point2D.setY(point3D.getY());
|
|
726 |
polygon2D.addVertex(point2D);
|
|
727 |
}
|
|
728 |
for (int r=0;r<gPolygon.getNumInteriorRings();r++){
|
|
729 |
Ring ring2D=(Ring)geomManager.create(TYPES.RING, Geometry.SUBTYPES.GEOM2D);
|
|
730 |
Ring ring3D=gPolygon.getInteriorRing(r);
|
|
731 |
for(int i=0;i<ring2D.getNumVertices();i++){
|
|
732 |
Point point2D=(Point)geomManager.create(TYPES.POINT, Geometry.SUBTYPES.GEOM2D);
|
|
733 |
Point point3D=ring3D.getVertex(i);
|
|
734 |
point2D.setX(point3D.getX());
|
|
735 |
point2D.setY(point3D.getY());
|
|
736 |
ring2D.addVertex(point2D);
|
|
737 |
}
|
|
738 |
polygon2D.addInteriorRing(ring2D);
|
|
739 |
}
|
|
740 |
((MultiPolygon)multiPolygon).addPrimitive(polygon2D);
|
|
741 |
} catch (CreateGeometryException e) {
|
|
742 |
getErrorHandler().addError(e);
|
|
743 |
}
|
|
744 |
}else{
|
|
745 |
((MultiPolygon)multiPolygon).addPrimitive((Polygon)polygon);
|
|
746 |
}
|
|
747 |
}
|
636 |
748 |
}
|
637 |
749 |
|
638 |
750 |
/* (non-Javadoc)
|
639 |
751 |
* @see org.gvsig.gpe.GPEContentHandler#addCurveToMultiCurve(java.lang.Object, java.lang.Object)
|
640 |
752 |
*/
|
641 |
753 |
public void addCurveToMultiCurve(Object curve, Object multiCurve) {
|
642 |
|
((MultiCurve)multiCurve).addCurve((Curve)curve);
|
|
754 |
//((MultiCurve)multiCurve).addCurve((Curve)curve);
|
|
755 |
addLineStringToMultiLineString(curve, multiCurve);
|
643 |
756 |
}
|
644 |
757 |
|
645 |
758 |
/* (non-Javadoc)
|
... | ... | |
655 |
768 |
for (int i=0; i<n; i++) {
|
656 |
769 |
((Curve)curve).addVertex(seg_cur.getVertex(i));
|
657 |
770 |
}
|
658 |
|
|
|
771 |
|
659 |
772 |
} else {
|
660 |
773 |
LOG.info("Discarded unexpected geometry class: "
|
661 |
774 |
+ (segment == null ? "NULL" : segment.getClass().getName()));
|
662 |
775 |
}
|
663 |
776 |
}
|
664 |
|
|
|
777 |
|
665 |
778 |
}
|
666 |
779 |
|
667 |
780 |
/* (non-Javadoc)
|
... | ... | |
683 |
796 |
*/
|
684 |
797 |
public Object startMultiCurve(String id, String srs, int dimension) {
|
685 |
798 |
try {
|
686 |
|
return geomManager.create(TYPES.MULTICURVE, getGeometrySubtype(dimension));
|
|
799 |
return geomManager.create(TYPES.MULTILINE, getGeometrySubtype(dimension));
|
687 |
800 |
} catch (CreateGeometryException e) {
|
688 |
801 |
getErrorHandler().addError(e);
|
689 |
802 |
}
|
... | ... | |
691 |
804 |
}
|
692 |
805 |
|
693 |
806 |
/* (non-Javadoc)
|
|
807 |
* @see org.gvsig.gpe.GPEContentHandler#startMultiCurve(java.lang.String, java.lang.String)
|
|
808 |
*/
|
|
809 |
public Object startMultiCurve(String id, String srs) {
|
|
810 |
return startMultiCurve(id,srs,Geometry.SUBTYPES.GEOM2D);
|
|
811 |
}
|
|
812 |
|
|
813 |
/* (non-Javadoc)
|
694 |
814 |
* @see org.gvsig.gpe.GPEContentHandler#addGeometryToMultiGeometry(java.lang.Object, java.lang.Object)
|
695 |
815 |
*/
|
696 |
816 |
public void addGeometryToMultiGeometry(Object geometry, Object multiGeometry) {
|
697 |
|
((MultiPrimitive)multiGeometry).addPrimitive((Primitive)geometry);
|
|
817 |
if (((Geometry)multiGeometry).getGeometryType().isTypeOf(TYPES.MULTILINE) ){
|
|
818 |
((MultiLine)multiGeometry).addPrimitive((Line)geometry);
|
|
819 |
}
|
|
820 |
if (((Geometry)multiGeometry).getGeometryType().isTypeOf(TYPES.MULTIPOINT) ){
|
|
821 |
((MultiPoint)multiGeometry).addPrimitive((Point)geometry);
|
|
822 |
}
|
|
823 |
if (((Geometry)multiGeometry).getGeometryType().isTypeOf(TYPES.MULTIPOLYGON) ){
|
|
824 |
((MultiPolygon)multiGeometry).addPrimitive((Polygon)geometry);
|
|
825 |
}
|
698 |
826 |
}
|
699 |
827 |
|
700 |
828 |
/* (non-Javadoc)
|
701 |
829 |
* @see org.gvsig.gpe.GPEContentHandler#startMultiGeometry(java.lang.String, java.lang.String)
|
702 |
830 |
*/
|
703 |
831 |
public Object startMultiGeometry(String id, String srs) {
|
704 |
|
try {
|
705 |
|
return geomManager.create(TYPES.AGGREGATE, SUBTYPES.GEOM2D);
|
706 |
|
} catch (CreateGeometryException e) {
|
707 |
|
getErrorHandler().addError(e);
|
708 |
|
}
|
|
832 |
// try {
|
|
833 |
// return geomManager.create(TYPES.AGGREGATE, SUBTYPES.GEOM2D);
|
|
834 |
// } catch (CreateGeometryException e) {
|
|
835 |
// getErrorHandler().addError(e);
|
|
836 |
// }
|
709 |
837 |
return null;
|
710 |
838 |
}
|
711 |
839 |
|
... | ... | |
715 |
843 |
public Object createNewOID() {
|
716 |
844 |
featureId++;
|
717 |
845 |
return String.valueOf(featureId);
|
718 |
|
}
|
|
846 |
}
|
719 |
847 |
|
720 |
848 |
/**
|
721 |
849 |
* @param envelope the envelope to set
|
... | ... | |
730 |
858 |
public void setFeatureType(EditableFeatureType featureType) {
|
731 |
859 |
this.featureType = featureType;
|
732 |
860 |
}
|
733 |
|
|
|
861 |
|
734 |
862 |
private int getGeometrySubtype(int dimension) {
|
735 |
863 |
switch(dimension) {
|
736 |
864 |
case 3:
|
737 |
865 |
return Geometry.SUBTYPES.GEOM3D;
|
738 |
866 |
default:
|
739 |
867 |
case 2:
|
740 |
|
return Geometry.SUBTYPES.GEOM2D;
|
|
868 |
return Geometry.SUBTYPES.GEOM2D;
|
741 |
869 |
}
|
742 |
870 |
}
|
743 |
871 |
}
|