Revision 19441 trunk/libraries/libDataSourceBaseDrivers/src/org/gvsig/data/datastores/vectorial/driver/shp/ShpDriver.java
ShpDriver.java | ||
---|---|---|
19 | 19 |
import org.gvsig.data.datastores.vectorial.driver.dbf.DBFDriver; |
20 | 20 |
import org.gvsig.data.datastores.vectorial.driver.shp.fileshp.SHP; |
21 | 21 |
import org.gvsig.data.datastores.vectorial.driver.shp.fileshp.ShapeFileHeader2; |
22 |
import org.gvsig.data.spatialprovisional.Extent; |
|
23 |
import org.gvsig.data.spatialprovisional.IExtent; |
|
22 | 24 |
import org.gvsig.data.vectorial.DefaultAttributeDescriptor; |
23 | 25 |
import org.gvsig.data.vectorial.IFeature; |
24 | 26 |
import org.gvsig.data.vectorial.IFeatureAttributeDescriptor; |
... | ... | |
26 | 28 |
import org.gvsig.data.vectorial.IFeatureID; |
27 | 29 |
import org.gvsig.data.vectorial.IFeatureType; |
28 | 30 |
import org.gvsig.data.vectorial.expansionadapter.FeatureManager; |
31 |
import org.gvsig.metadata.IMetadata; |
|
32 |
import org.gvsig.metadata.IMetadataManager; |
|
33 |
import org.gvsig.metadata.MetadataManager; |
|
29 | 34 |
|
30 | 35 |
import com.iver.cit.gvsig.fmap.core.FShape; |
31 | 36 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
... | ... | |
44 | 49 |
private FileChannel channelShx; |
45 | 50 |
private BigByteBuffer2 bbShx; |
46 | 51 |
private int type; |
47 |
private Rectangle2D extent;
|
|
52 |
private IExtent extent;
|
|
48 | 53 |
private IFeatureType featureType; |
49 | 54 |
public ShpDriver() { |
50 | 55 |
super(); |
... | ... | |
107 | 112 |
// read the header |
108 | 113 |
myHeader.readHeader(bb); |
109 | 114 |
|
110 |
extent = new Rectangle2D.Double(myHeader.myXmin, myHeader.myYmin, |
|
111 |
myHeader.myXmax - myHeader.myXmin, |
|
112 |
myHeader.myYmax - myHeader.myYmin); |
|
115 |
extent = new Extent(myHeader.myXmin, myHeader.myYmin,myHeader.myXmax,myHeader.myYmax); |
|
116 |
// extent = new Rectangle2D.Double(myHeader.myXmin, myHeader.myYmin, |
|
117 |
// myHeader.myXmax - myHeader.myXmin, |
|
118 |
// myHeader.myYmax - myHeader.myYmin); |
|
113 | 119 |
|
114 | 120 |
type = myHeader.myShapeType; |
115 | 121 |
|
... | ... | |
496 | 502 |
return DRIVER_NAME; |
497 | 503 |
} |
498 | 504 |
|
499 |
public Rectangle2D getFullExtent() {
|
|
505 |
private IExtent getFullExtent() {
|
|
500 | 506 |
return extent; |
501 | 507 |
} |
502 | 508 |
|
... | ... | |
545 | 551 |
* |
546 | 552 |
* @throws IOException |
547 | 553 |
*/ |
548 |
private synchronized Rectangle2D.Double readRectangle(BigByteBuffer2 in){
|
|
549 |
Rectangle2D.Double tempRect = new Rectangle2D.Double(); |
|
554 |
private synchronized IExtent readRectangle(BigByteBuffer2 in){
|
|
555 |
|
|
550 | 556 |
in.order(ByteOrder.LITTLE_ENDIAN); |
551 |
tempRect.x = in.getDouble();
|
|
552 |
tempRect.y = in.getDouble();
|
|
557 |
double x = in.getDouble();
|
|
558 |
double y = in.getDouble();
|
|
553 | 559 |
|
554 |
tempRect.width = in.getDouble() - tempRect.x;
|
|
560 |
double x2 = in.getDouble();
|
|
555 | 561 |
|
556 |
if (tempRect.width == 0) {
|
|
557 |
tempRect.width = 0.2;
|
|
558 |
tempRect.x -= 0.1;
|
|
562 |
if (x2-x == 0) {
|
|
563 |
x2 = 0.2;
|
|
564 |
x -= 0.1; |
|
559 | 565 |
} |
560 | 566 |
|
561 |
tempRect.height = in.getDouble() - tempRect.y;
|
|
567 |
double y2 = in.getDouble();
|
|
562 | 568 |
|
563 |
if (tempRect.height == 0) {
|
|
564 |
tempRect.height = 0.2;
|
|
565 |
tempRect.y -= 0.1;
|
|
569 |
if (y2-y == 0) {
|
|
570 |
y2 = 0.2;
|
|
571 |
y -= 0.1; |
|
566 | 572 |
} |
567 |
|
|
573 |
IExtent tempRect = new Extent(x,y,x2,y2); |
|
568 | 574 |
return tempRect; |
569 | 575 |
} |
570 | 576 |
|
... | ... | |
572 | 578 |
return true; |
573 | 579 |
} |
574 | 580 |
|
575 |
public List getAllSRS() {
|
|
581 |
private String getSRS() {
|
|
576 | 582 |
// TODO Auto-generated method stub |
577 | 583 |
return null; |
578 | 584 |
} |
579 | 585 |
|
580 |
public Rectangle2D getBoundingBox2D(long featureIndex) {
|
|
586 |
public IExtent getBoundingBox(long featureIndex) {
|
|
581 | 587 |
Point2D p = new Point2D.Double(); |
582 |
Rectangle2D BoundingBox = new Rectangle2D.Double();
|
|
588 |
IExtent BoundingBox = null;
|
|
583 | 589 |
try { |
584 | 590 |
bb.position(getPositionForRecord(featureIndex)); |
585 | 591 |
}catch (Exception e) { |
... | ... | |
603 | 609 |
case (SHP.POINT2D): |
604 | 610 |
case (SHP.POINT3D): |
605 | 611 |
p = readPoint(bb); |
606 |
BoundingBox = new Rectangle2D.Double(p.getX() - 0.1, |
|
607 |
p.getY() - 0.1, 0.2, 0.2); |
|
612 |
BoundingBox = new Extent(p.getX() - 0.1, p.getY() - 0.1,p.getX()+0.2,p.getY()+0.2); |
|
613 |
// new Rectangle2D.Double(p.getX() - 0.1, |
|
614 |
// p.getY() - 0.1, 0.2, 0.2); |
|
608 | 615 |
|
609 | 616 |
break; |
610 | 617 |
|
... | ... | |
653 | 660 |
|
654 | 661 |
return auxType; |
655 | 662 |
} |
663 |
public IMetadata getMetadata() { |
|
664 |
if (metadata==null){ |
|
665 |
IMetadataManager manager=MetadataManager.getManager(); |
|
666 |
metadata=manager.create(DRIVER_NAME); |
|
667 |
IExtent extent=getFullExtent(); |
|
668 |
metadata.set("extent",extent); |
|
669 |
String srs=getSRS(); |
|
670 |
metadata.set("srs",srs); |
|
671 |
} |
|
672 |
return metadata; |
|
673 |
} |
|
656 | 674 |
} |
Also available in: Unified diff