@@ -78,19 +78,19 @@ public function loadFromFile(ShapeFile $shapeFile, $dbfFile): void
78
78
}
79
79
80
80
match ($ this ->shapeType ) {
81
- ShapeType::NULL => $ this ->loadNullRecord (),
82
- ShapeType::POINT => $ this ->loadPointRecord (),
83
- ShapeType::POINT_M => $ this ->loadPointMRecord (),
84
- ShapeType::POINT_Z => $ this ->loadPointZRecord (),
85
- ShapeType::POLY_LINE => $ this ->loadPolyLineRecord (),
86
- ShapeType::POLY_LINE_M => $ this ->loadPolyLineMRecord (),
87
- ShapeType::POLY_LINE_Z => $ this ->loadPolyLineZRecord (),
88
- ShapeType::POLYGON => $ this ->loadPolygonRecord (),
89
- ShapeType::POLYGON_M => $ this ->loadPolygonMRecord (),
90
- ShapeType::POLYGON_Z => $ this ->loadPolygonZRecord (),
91
- ShapeType::MULTI_POINT => $ this ->loadMultiPointRecord (),
92
- ShapeType::MULTI_POINT_M => $ this ->loadMultiPointMRecord (),
93
- ShapeType::MULTI_POINT_Z => $ this ->loadMultiPointZRecord (),
81
+ ShapeType::Null => $ this ->loadNullRecord (),
82
+ ShapeType::Point => $ this ->loadPointRecord (),
83
+ ShapeType::PointM => $ this ->loadPointMRecord (),
84
+ ShapeType::PointZ => $ this ->loadPointZRecord (),
85
+ ShapeType::PolyLine => $ this ->loadPolyLineRecord (),
86
+ ShapeType::PolyLineM => $ this ->loadPolyLineMRecord (),
87
+ ShapeType::PolyLineZ => $ this ->loadPolyLineZRecord (),
88
+ ShapeType::Polygon => $ this ->loadPolygonRecord (),
89
+ ShapeType::PolygonM => $ this ->loadPolygonMRecord (),
90
+ ShapeType::PolygonZ => $ this ->loadPolygonZRecord (),
91
+ ShapeType::MultiPoint => $ this ->loadMultiPointRecord (),
92
+ ShapeType::MultiPointM => $ this ->loadMultiPointMRecord (),
93
+ ShapeType::MultiPointZ => $ this ->loadMultiPointZRecord (),
94
94
default => $ this ->reportInvalidShapeTypeError (),
95
95
};
96
96
@@ -125,19 +125,19 @@ public function saveToFile($shpFile, $dbfFile, int $recordNumber): void
125
125
$ this ->saveHeaders ();
126
126
127
127
match ($ this ->shapeType ) {
128
- ShapeType::NULL => null , // Nothing to save
129
- ShapeType::POINT => $ this ->savePointRecord (),
130
- ShapeType::POINT_M => $ this ->savePointMRecord (),
131
- ShapeType::POINT_Z => $ this ->savePointZRecord (),
132
- ShapeType::POLY_LINE => $ this ->savePolyLineRecord (),
133
- ShapeType::POLY_LINE_M => $ this ->savePolyLineMRecord (),
134
- ShapeType::POLY_LINE_Z => $ this ->savePolyLineZRecord (),
135
- ShapeType::POLYGON => $ this ->savePolygonRecord (),
136
- ShapeType::POLYGON_M => $ this ->savePolygonMRecord (),
137
- ShapeType::POLYGON_Z => $ this ->savePolygonZRecord (),
138
- ShapeType::MULTI_POINT => $ this ->saveMultiPointRecord (),
139
- ShapeType::MULTI_POINT_M => $ this ->saveMultiPointMRecord (),
140
- ShapeType::MULTI_POINT_Z => $ this ->saveMultiPointZRecord (),
128
+ ShapeType::Null => null , // Nothing to save
129
+ ShapeType::Point => $ this ->savePointRecord (),
130
+ ShapeType::PointM => $ this ->savePointMRecord (),
131
+ ShapeType::PointZ => $ this ->savePointZRecord (),
132
+ ShapeType::PolyLine => $ this ->savePolyLineRecord (),
133
+ ShapeType::PolyLineM => $ this ->savePolyLineMRecord (),
134
+ ShapeType::PolyLineZ => $ this ->savePolyLineZRecord (),
135
+ ShapeType::Polygon => $ this ->savePolygonRecord (),
136
+ ShapeType::PolygonM => $ this ->savePolygonMRecord (),
137
+ ShapeType::PolygonZ => $ this ->savePolygonZRecord (),
138
+ ShapeType::MultiPoint => $ this ->saveMultiPointRecord (),
139
+ ShapeType::MultiPointM => $ this ->saveMultiPointMRecord (),
140
+ ShapeType::MultiPointZ => $ this ->saveMultiPointZRecord (),
141
141
default => $ this ->reportInvalidShapeTypeError (),
142
142
};
143
143
@@ -185,7 +185,7 @@ private function loadData(string $type, int $count): mixed
185
185
*/
186
186
private function loadHeaders (): void
187
187
{
188
- $ this ->shapeType = ShapeType::NULL ;
188
+ $ this ->shapeType = ShapeType::Unknown ;
189
189
$ recordNumber = $ this ->loadData ('N ' , 4 );
190
190
if ($ recordNumber === false ) {
191
191
return ;
@@ -206,7 +206,7 @@ private function loadHeaders(): void
206
206
return ;
207
207
}
208
208
209
- $ this ->shapeType = ShapeType::tryFrom ((int ) $ shapeType ) ?? ShapeType::NULL ;
209
+ $ this ->shapeType = ShapeType::tryFrom ((int ) $ shapeType ) ?? ShapeType::Unknown ;
210
210
}
211
211
212
212
/**
@@ -604,30 +604,30 @@ public function addPoint(array $point, int $partIndex = 0): void
604
604
{
605
605
$ point = $ this ->adjustPoint ($ point );
606
606
switch ($ this ->shapeType ) {
607
- case ShapeType::NULL :
607
+ case ShapeType::Null :
608
608
//Don't add anything
609
609
return ;
610
610
611
- case ShapeType::POINT :
612
- case ShapeType::POINT_Z :
613
- case ShapeType::POINT_M :
611
+ case ShapeType::Point :
612
+ case ShapeType::PointZ :
613
+ case ShapeType::PointM :
614
614
//Substitutes the value of the current point
615
615
$ this ->shpData = $ point ;
616
616
break ;
617
- case ShapeType::POLY_LINE :
618
- case ShapeType::POLYGON :
619
- case ShapeType::POLY_LINE_Z :
620
- case ShapeType::POLYGON_Z :
621
- case ShapeType::POLY_LINE_M :
622
- case ShapeType::POLYGON_M :
617
+ case ShapeType::PolyLine :
618
+ case ShapeType::Polygon :
619
+ case ShapeType::PolyLineZ :
620
+ case ShapeType::PolygonZ :
621
+ case ShapeType::PolyLineM :
622
+ case ShapeType::PolygonM :
623
623
//Adds a new point to the selected part
624
624
$ this ->shpData ['parts ' ][$ partIndex ]['points ' ][] = $ point ;
625
625
$ this ->shpData ['numparts ' ] = count ($ this ->shpData ['parts ' ]);
626
626
$ this ->shpData ['numpoints ' ] = 1 + ($ this ->shpData ['numpoints ' ] ?? 0 );
627
627
break ;
628
- case ShapeType::MULTI_POINT :
629
- case ShapeType::MULTI_POINT_Z :
630
- case ShapeType::MULTI_POINT_M :
628
+ case ShapeType::MultiPoint :
629
+ case ShapeType::MultiPointZ :
630
+ case ShapeType::MultiPointM :
631
631
//Adds a new point
632
632
$ this ->shpData ['points ' ][] = $ point ;
633
633
$ this ->shpData ['numpoints ' ] = 1 + ($ this ->shpData ['numpoints ' ] ?? 0 );
@@ -650,30 +650,30 @@ public function addPoint(array $point, int $partIndex = 0): void
650
650
public function deletePoint (int $ pointIndex = 0 , int $ partIndex = 0 ): void
651
651
{
652
652
switch ($ this ->shapeType ) {
653
- case ShapeType::NULL :
653
+ case ShapeType::Null :
654
654
//Don't delete anything
655
655
break ;
656
- case ShapeType::POINT :
657
- case ShapeType::POINT_Z :
658
- case ShapeType::POINT_M :
656
+ case ShapeType::Point :
657
+ case ShapeType::PointZ :
658
+ case ShapeType::PointM :
659
659
//Sets the value of the point to zero
660
660
$ this ->shpData ['x ' ] = 0.0 ;
661
661
$ this ->shpData ['y ' ] = 0.0 ;
662
- if (in_array ($ this ->shapeType , [ShapeType::POINT_Z , ShapeType::POINT_M ], true )) {
662
+ if (in_array ($ this ->shapeType , [ShapeType::PointZ , ShapeType::PointM ], true )) {
663
663
$ this ->shpData ['m ' ] = 0.0 ;
664
664
}
665
665
666
- if ($ this ->shapeType === ShapeType::POINT_Z ) {
666
+ if ($ this ->shapeType === ShapeType::PointZ ) {
667
667
$ this ->shpData ['z ' ] = 0.0 ;
668
668
}
669
669
670
670
break ;
671
- case ShapeType::POLY_LINE :
672
- case ShapeType::POLYGON :
673
- case ShapeType::POLY_LINE_Z :
674
- case ShapeType::POLYGON_Z :
675
- case ShapeType::POLY_LINE_M :
676
- case ShapeType::POLYGON_M :
671
+ case ShapeType::PolyLine :
672
+ case ShapeType::Polygon :
673
+ case ShapeType::PolyLineZ :
674
+ case ShapeType::PolygonZ :
675
+ case ShapeType::PolyLineM :
676
+ case ShapeType::PolygonM :
677
677
//Deletes the point from the selected part, if exists
678
678
if (
679
679
isset ($ this ->shpData ['parts ' ][$ partIndex ])
@@ -693,9 +693,9 @@ public function deletePoint(int $pointIndex = 0, int $partIndex = 0): void
693
693
}
694
694
695
695
break ;
696
- case ShapeType::MULTI_POINT :
697
- case ShapeType::MULTI_POINT_Z :
698
- case ShapeType::MULTI_POINT_M :
696
+ case ShapeType::MultiPoint :
697
+ case ShapeType::MultiPointZ :
698
+ case ShapeType::MultiPointM :
699
699
//Deletes the point, if exists
700
700
if (isset ($ this ->shpData ['points ' ][$ pointIndex ])) {
701
701
$ count = count ($ this ->shpData ['points ' ]) - 1 ;
@@ -723,52 +723,52 @@ public function getContentLength(): int|null
723
723
// The content length for a record is the length of the record contents section measured in 16-bit words.
724
724
// one coordinate makes 4 16-bit words (64 bit double)
725
725
switch ($ this ->shapeType ) {
726
- case ShapeType::NULL :
726
+ case ShapeType::Null :
727
727
$ result = 0 ;
728
728
break ;
729
- case ShapeType::POINT :
729
+ case ShapeType::Point :
730
730
$ result = 10 ;
731
731
break ;
732
- case ShapeType::POINT_M :
732
+ case ShapeType::PointM :
733
733
$ result = 10 + 4 ;
734
734
break ;
735
- case ShapeType::POINT_Z :
735
+ case ShapeType::PointZ :
736
736
$ result = 10 + 8 ;
737
737
break ;
738
- case ShapeType::POLY_LINE :
739
- case ShapeType::POLYGON :
738
+ case ShapeType::PolyLine :
739
+ case ShapeType::Polygon :
740
740
$ count = count ($ this ->shpData ['parts ' ]);
741
741
$ result = 22 + 2 * $ count ;
742
742
for ($ i = 0 ; $ i < $ count ; ++$ i ) {
743
743
$ result += 8 * count ($ this ->shpData ['parts ' ][$ i ]['points ' ]);
744
744
}
745
745
746
746
break ;
747
- case ShapeType::POLY_LINE_M :
748
- case ShapeType::POLYGON_M :
747
+ case ShapeType::PolyLineM :
748
+ case ShapeType::PolygonM :
749
749
$ count = count ($ this ->shpData ['parts ' ]);
750
750
$ result = 22 + (2 * 4 ) + 2 * $ count ;
751
751
for ($ i = 0 ; $ i < $ count ; ++$ i ) {
752
752
$ result += (8 + 4 ) * count ($ this ->shpData ['parts ' ][$ i ]['points ' ]);
753
753
}
754
754
755
755
break ;
756
- case ShapeType::POLY_LINE_Z :
757
- case ShapeType::POLYGON_Z :
756
+ case ShapeType::PolyLineZ :
757
+ case ShapeType::PolygonZ :
758
758
$ count = count ($ this ->shpData ['parts ' ]);
759
759
$ result = 22 + (4 * 4 ) + 2 * $ count ;
760
760
for ($ i = 0 ; $ i < $ count ; ++$ i ) {
761
761
$ result += (8 + 8 ) * count ($ this ->shpData ['parts ' ][$ i ]['points ' ]);
762
762
}
763
763
764
764
break ;
765
- case ShapeType::MULTI_POINT :
765
+ case ShapeType::MultiPoint :
766
766
$ result = 20 + 8 * count ($ this ->shpData ['points ' ]);
767
767
break ;
768
- case ShapeType::MULTI_POINT_M :
768
+ case ShapeType::MultiPointM :
769
769
$ result = 20 + (2 * 4 ) + (8 + 4 ) * count ($ this ->shpData ['points ' ]);
770
770
break ;
771
- case ShapeType::MULTI_POINT_Z :
771
+ case ShapeType::MultiPointZ :
772
772
$ result = 20 + (4 * 4 ) + (8 + 8 ) * count ($ this ->shpData ['points ' ]);
773
773
break ;
774
774
default :
0 commit comments