Revision 5879
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/shp/IndexedShpDriver.java | ||
---|---|---|
334 | 334 |
* @throws IOException DOCUMENT ME! |
335 | 335 |
*/ |
336 | 336 |
public synchronized IGeometry getShape(int index) throws IOException { |
337 |
IGeometry geom=null; |
|
337 | 338 |
Point2D.Double p = new Point2D.Double(); |
338 | 339 |
int numParts; |
339 | 340 |
int numPoints; |
... | ... | |
365 | 366 |
switch (type) { |
366 | 367 |
case (SHP.POINT2D): |
367 | 368 |
p = readPoint(bb); |
369 |
geom=ShapeFactory.createPoint2D(p.getX(), p.getY()); |
|
370 |
geom.setGeometryType(FShape.POINT); |
|
371 |
return geom; |
|
368 | 372 |
|
369 |
return ShapeFactory.createPoint2D(p.getX(), p.getY()); |
|
370 |
|
|
371 | 373 |
case (SHP.POLYLINE2D): |
372 | 374 |
|
373 |
//BoundingBox = readRectangle(bb); |
|
374 |
//bb.getDouble(); |
|
375 |
//bb.getDouble(); |
|
376 |
//bb.getDouble(); |
|
377 |
//bb.getDouble(); |
|
378 | 375 |
bb.position(bb.position() + 32); |
379 | 376 |
numParts = bb.getInt(); |
380 | 377 |
numPoints = bb.getInt(); |
... | ... | |
405 | 402 |
elShape.lineTo(p.x, p.y); |
406 | 403 |
} |
407 | 404 |
} |
408 |
|
|
409 |
return ShapeFactory.createPolyline2D(elShape);
|
|
410 |
|
|
405 |
geom = ShapeFactory.createPolyline2D(elShape); |
|
406 |
geom.setGeometryType(FShape.LINE);
|
|
407 |
return geom; |
|
411 | 408 |
case (SHP.POLYGON2D): |
412 | 409 |
|
413 | 410 |
// BoundingBox = readRectangle(bb); |
... | ... | |
445 | 442 |
elShape.lineTo(p.x, p.y); |
446 | 443 |
} |
447 | 444 |
} |
445 |
geom = ShapeFactory.createPolygon2D(elShape); |
|
446 |
geom.setGeometryType(FShape.POLYGON); |
|
447 |
return geom; |
|
448 | 448 |
|
449 |
return ShapeFactory.createPolygon2D(elShape); |
|
450 |
|
|
451 | 449 |
case (SHP.POINT3D): |
452 | 450 |
|
453 | 451 |
double x = bb.getDouble(); |
454 | 452 |
double y = bb.getDouble(); |
455 | 453 |
double z = bb.getDouble(); |
454 |
geom = ShapeFactory.createPoint3D(x, y, z); |
|
455 |
geom.setGeometryType(FShape.POINT); |
|
456 |
return geom; |
|
456 | 457 |
|
457 |
return ShapeFactory.createPoint3D(x, y, z); |
|
458 |
|
|
459 | 458 |
case (SHP.POLYLINE3D): |
460 | 459 |
bb.position(bb.position() + 32); |
461 | 460 |
numParts = bb.getInt(); |
... | ... | |
492 | 491 |
for (i = 0; i < numPoints; i++) { |
493 | 492 |
pZ[i] = bb.getDouble(); |
494 | 493 |
} |
495 |
|
|
496 |
return ShapeFactory.createPolyline3D(elShape, pZ); |
|
494 |
geom = ShapeFactory.createPolyline3D(elShape, pZ); |
|
495 |
geom.setGeometryType(FShape.LINE); |
|
496 |
return geom; |
|
497 | 497 |
case (SHP.POLYGON3D): |
498 | 498 |
bb.position(bb.position() + 32); |
499 | 499 |
numParts = bb.getInt(); |
... | ... | |
530 | 530 |
for (i = 0; i < numPoints; i++) { |
531 | 531 |
poZ[i] = bb.getDouble(); |
532 | 532 |
} |
533 |
geom = ShapeFactory.createPolygon3D(elShape, poZ); |
|
534 |
geom.setGeometryType(FShape.POLYGON); |
|
535 |
return geom; |
|
533 | 536 |
|
534 |
return ShapeFactory.createPolygon3D(elShape, poZ); |
|
535 |
|
|
536 | 537 |
case (SHP.MULTIPOINT2D): |
537 | 538 |
bb.position(bb.position() + 32); |
538 | 539 |
numPoints = bb.getInt(); |
... | ... | |
544 | 545 |
tempX[i] = bb.getDouble(); |
545 | 546 |
tempY[i] = bb.getDouble(); |
546 | 547 |
} |
548 |
geom = ShapeFactory.createMultipoint2D(tempX, tempY); |
|
549 |
geom.setGeometryType(FShape.POINT); |
|
550 |
return geom; |
|
547 | 551 |
|
548 |
return ShapeFactory.createMultipoint2D(tempX, tempY); |
|
549 |
|
|
550 | 552 |
case (SHP.MULTIPOINT3D): |
551 | 553 |
bb.position(bb.position() + 32); |
552 | 554 |
numPoints = bb.getInt(); |
... | ... | |
564 | 566 |
for (i = 0; i < numPoints; i++) { |
565 | 567 |
temZ[i] = bb.getDouble(); |
566 | 568 |
} |
567 |
return ShapeFactory.createMultipoint3D(temX, temY, temZ); |
|
569 |
geom = ShapeFactory.createMultipoint3D(temX, temY, temZ); |
|
570 |
geom.setGeometryType(FShape.POINT); |
|
571 |
return geom; |
|
568 | 572 |
} |
569 | 573 |
|
570 |
return null;
|
|
574 |
return geom;
|
|
571 | 575 |
} |
572 | 576 |
|
573 | 577 |
/** |
... | ... | |
627 | 631 |
extent = new Rectangle2D.Double(myHeader.myXmin, myHeader.myYmin, |
628 | 632 |
myHeader.myXmax - myHeader.myXmin, |
629 | 633 |
myHeader.myYmax - myHeader.myYmin); |
630 |
|
|
634 |
|
|
631 | 635 |
type = myHeader.myShapeType; |
632 |
|
|
636 |
|
|
633 | 637 |
double x = myHeader.myXmin; |
634 | 638 |
double y = myHeader.myYmin; |
635 | 639 |
double w = myHeader.myXmax - myHeader.myXmin; |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/VectorialEditableAdapter.java | ||
---|---|---|
45 | 45 |
* |
46 | 46 |
* $Id$ |
47 | 47 |
* $Log$ |
48 |
* Revision 1.54 2006-06-01 16:15:16 fjp |
|
48 |
* Revision 1.55 2006-06-16 10:12:36 caballero |
|
49 |
* setGeometryType |
|
50 |
* |
|
51 |
* Revision 1.54 2006/06/01 16:15:16 fjp |
|
49 | 52 |
* Escritura que permite crear drivers de manera m?s sencilla. |
50 | 53 |
* |
51 | 54 |
* Revision 1.53 2006/05/30 13:03:41 fjp |
... | ... | |
220 | 223 |
import com.hardcode.gdbms.engine.values.Value; |
221 | 224 |
import com.iver.cit.gvsig.fmap.DriverException; |
222 | 225 |
import com.iver.cit.gvsig.fmap.core.DefaultFeature; |
226 |
import com.iver.cit.gvsig.fmap.core.FGeometryCollection; |
|
227 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
|
228 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
|
223 | 229 |
import com.iver.cit.gvsig.fmap.core.FShape; |
230 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
|
224 | 231 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
225 | 232 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
226 | 233 |
import com.iver.cit.gvsig.fmap.core.IRow; |
234 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
227 | 235 |
import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
228 | 236 |
import com.iver.cit.gvsig.fmap.drivers.BoundedShapes; |
229 | 237 |
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes; |
... | ... | |
707 | 715 |
*/ |
708 | 716 |
public int doAddRow(IRow feat, int sourceType) throws DriverIOException, |
709 | 717 |
IOException { |
718 |
|
|
719 |
validate((DefaultFeature)feat); |
|
720 |
|
|
710 | 721 |
int calculatedIndex = super.doAddRow(feat, sourceType); |
711 | 722 |
// Actualiza el ?ndice espacial |
712 | 723 |
IGeometry g = ((IFeature) feat).getGeometry(); |
... | ... | |
716 | 727 |
|
717 | 728 |
return calculatedIndex; |
718 | 729 |
} |
730 |
//TODO para validar si la geometria es de un tipo que se pueda a?adir a este VectorialEditableAdapter |
|
731 |
private void validate(DefaultFeature feat) throws DriverIOException { |
|
732 |
int typeLayer=getDriver().getShapeType(); |
|
733 |
IGeometry geom=feat.getGeometry(); |
|
734 |
geom.setGeometryType(typeLayer); |
|
735 |
feat.setGeometry(geom); |
|
736 |
/* int typeLayer=getDriver().getShapeType(); |
|
737 |
IGeometry geom=feat.getGeometry(); |
|
738 |
if (geom instanceof FGeometryCollection) { |
|
739 |
((FGeometryCollection)geom).setGeometryType(typeLayer); |
|
740 |
return; |
|
741 |
} |
|
719 | 742 |
|
743 |
FShape shape=(FShape)geom.getInternalShape(); |
|
744 |
int typeShape=shape.getShapeType(); |
|
745 |
switch (typeLayer) { |
|
746 |
case FShape.POINT: |
|
747 |
|
|
748 |
break; |
|
749 |
case FShape.LINE: |
|
750 |
//FPolyline2D line=(FPolyline2D)shape; |
|
751 |
switch (typeShape) { |
|
752 |
case FShape.ARC: |
|
753 |
case FShape.CIRCLE: |
|
754 |
case FShape.ELLIPSE: |
|
755 |
case FShape.POLYGON: |
|
756 |
GeneralPathX gpx=new GeneralPathX(); |
|
757 |
gpx.append(shape.getPathIterator(null),true); |
|
758 |
shape=new FPolyline2D(gpx); |
|
759 |
//shape=line; |
|
760 |
break; |
|
761 |
} |
|
762 |
break; |
|
763 |
case FShape.POLYGON: |
|
764 |
|
|
765 |
switch (typeShape) { |
|
766 |
case FShape.CIRCLE: |
|
767 |
case FShape.ELLIPSE: |
|
768 |
case FShape.LINE: |
|
769 |
GeneralPathX gpx=new GeneralPathX(); |
|
770 |
gpx.append(shape.getPathIterator(null),true); |
|
771 |
shape=new FPolygon2D(gpx); |
|
772 |
break; |
|
773 |
} |
|
774 |
break; |
|
775 |
} |
|
776 |
feat.setGeometry(ShapeFactory.createGeometry(shape)); |
|
777 |
*/ |
|
778 |
} |
|
779 |
|
|
720 | 780 |
/** |
721 | 781 |
* Se desmarca como invalidada en el fichero de expansion o como eliminada |
722 | 782 |
* en el fichero original |
Also available in: Unified diff