@@ -2014,13 +2014,13 @@ public function decodePoint(string $wkb): array
20142014
20152015 $ bin = hex2bin ($ wkb );
20162016 if ($ bin === false ) {
2017- throw new \ RuntimeException ('Invalid hex WKB string ' );
2017+ throw new DatabaseException ('Invalid hex WKB string ' );
20182018 }
20192019
20202020 $ isLE = ord ($ bin [0 ]) === 1 ;
20212021 $ type = unpack ($ isLE ? 'V ' : 'N ' , substr ($ bin , 1 , 4 ));
20222022 if ($ type === false ) {
2023- throw new \ RuntimeException ('Failed to unpack type from WKB ' );
2023+ throw new DatabaseException ('Failed to unpack type from WKB ' );
20242024 }
20252025
20262026 $ type = $ type [1 ];
@@ -2030,14 +2030,14 @@ public function decodePoint(string $wkb): array
20302030
20312031 $ x = unpack ($ fmt , substr ($ bin , $ offset , 8 ));
20322032 if ($ x === false ) {
2033- throw new \ RuntimeException ('Failed to unpack double from WKB ' );
2033+ throw new DatabaseException ('Failed to unpack double from WKB ' );
20342034 }
20352035
20362036 $ x = (float )$ x [1 ];
20372037
20382038 $ y = unpack ($ fmt , substr ($ bin , $ offset + 8 , 8 ));
20392039 if ($ y === false ) {
2040- throw new \ RuntimeException ('Failed to unpack Y coordinate from WKB ' );
2040+ throw new DatabaseException ('Failed to unpack Y coordinate from WKB ' );
20412041 }
20422042
20432043 $ y = (float )$ y [1 ];
@@ -2062,33 +2062,33 @@ public function decodeLinestring(mixed $wkb): array
20622062 if (ctype_xdigit ($ wkb )) {
20632063 $ wkb = hex2bin ($ wkb );
20642064 if ($ wkb === false ) {
2065- throw new \ RuntimeException ("Failed to convert hex WKB to binary. " );
2065+ throw new DatabaseException ("Failed to convert hex WKB to binary. " );
20662066 }
20672067 }
20682068
20692069 if (strlen ($ wkb ) < 9 ) {
2070- throw new \ RuntimeException ("WKB too short to be a valid geometry " );
2070+ throw new DatabaseException ("WKB too short to be a valid geometry " );
20712071 }
20722072
20732073 $ byteOrder = ord ($ wkb [0 ]);
20742074 if ($ byteOrder === 0 ) {
2075- throw new \ RuntimeException ("Big-endian WKB not supported " );
2075+ throw new DatabaseException ("Big-endian WKB not supported " );
20762076 } elseif ($ byteOrder !== 1 ) {
2077- throw new \ RuntimeException ("Invalid byte order in WKB " );
2077+ throw new DatabaseException ("Invalid byte order in WKB " );
20782078 }
20792079
20802080 // Type + SRID flag
20812081 $ typeField = unpack ('V ' , substr ($ wkb , 1 , 4 ));
20822082 if ($ typeField === false ) {
2083- throw new \ RuntimeException ('Failed to unpack the type field from WKB. ' );
2083+ throw new DatabaseException ('Failed to unpack the type field from WKB. ' );
20842084 }
20852085
20862086 $ typeField = $ typeField [1 ];
20872087 $ geomType = $ typeField & 0xFF ;
20882088 $ hasSRID = ($ typeField & 0x20000000 ) !== 0 ;
20892089
20902090 if ($ geomType !== 2 ) { // 2 = LINESTRING
2091- throw new \ RuntimeException ("Not a LINESTRING geometry type, got {$ geomType }" );
2091+ throw new DatabaseException ("Not a LINESTRING geometry type, got {$ geomType }" );
20922092 }
20932093
20942094 $ offset = 5 ;
@@ -2098,7 +2098,7 @@ public function decodeLinestring(mixed $wkb): array
20982098
20992099 $ numPoints = unpack ('V ' , substr ($ wkb , $ offset , 4 ));
21002100 if ($ numPoints === false ) {
2101- throw new \ RuntimeException ("Failed to unpack number of points at offset {$ offset }. " );
2101+ throw new DatabaseException ("Failed to unpack number of points at offset {$ offset }. " );
21022102 }
21032103
21042104 $ numPoints = $ numPoints [1 ];
@@ -2108,7 +2108,7 @@ public function decodeLinestring(mixed $wkb): array
21082108 for ($ i = 0 ; $ i < $ numPoints ; $ i ++) {
21092109 $ x = unpack ('e ' , substr ($ wkb , $ offset , 8 ));
21102110 if ($ x === false ) {
2111- throw new \ RuntimeException ("Failed to unpack X coordinate at offset {$ offset }. " );
2111+ throw new DatabaseException ("Failed to unpack X coordinate at offset {$ offset }. " );
21122112 }
21132113
21142114 $ x = (float ) $ x [1 ];
@@ -2117,7 +2117,7 @@ public function decodeLinestring(mixed $wkb): array
21172117
21182118 $ y = unpack ('e ' , substr ($ wkb , $ offset , 8 ));
21192119 if ($ y === false ) {
2120- throw new \ RuntimeException ("Failed to unpack Y coordinate at offset {$ offset }. " );
2120+ throw new DatabaseException ("Failed to unpack Y coordinate at offset {$ offset }. " );
21212121 }
21222122
21232123 $ y = (float ) $ y [1 ];
@@ -2151,28 +2151,28 @@ public function decodePolygon(string $wkb): array
21512151 if (preg_match ('/^[0-9a-fA-F]+$/ ' , $ wkb )) {
21522152 $ wkb = hex2bin ($ wkb );
21532153 if ($ wkb === false ) {
2154- throw new \ RuntimeException ("Invalid hex WKB " );
2154+ throw new DatabaseException ("Invalid hex WKB " );
21552155 }
21562156 }
21572157
21582158 if (strlen ($ wkb ) < 9 ) {
2159- throw new \ RuntimeException ("WKB too short " );
2159+ throw new DatabaseException ("WKB too short " );
21602160 }
21612161
21622162 $ uInt32 = 'V ' ; // little-endian 32-bit unsigned
21632163 $ uDouble = 'd ' ; // little-endian double
21642164
21652165 $ typeInt = unpack ($ uInt32 , substr ($ wkb , 1 , 4 ));
21662166 if ($ typeInt === false ) {
2167- throw new \ RuntimeException ('Failed to unpack type field from WKB. ' );
2167+ throw new DatabaseException ('Failed to unpack type field from WKB. ' );
21682168 }
21692169
21702170 $ typeInt = (int ) $ typeInt [1 ];
21712171 $ hasSrid = ($ typeInt & 0x20000000 ) !== 0 ;
21722172 $ geomType = $ typeInt & 0xFF ;
21732173
21742174 if ($ geomType !== 3 ) { // 3 = POLYGON
2175- throw new \ RuntimeException ("Not a POLYGON geometry type, got {$ geomType }" );
2175+ throw new DatabaseException ("Not a POLYGON geometry type, got {$ geomType }" );
21762176 }
21772177
21782178 $ offset = 5 ;
@@ -2183,7 +2183,7 @@ public function decodePolygon(string $wkb): array
21832183 // Number of rings
21842184 $ numRings = unpack ($ uInt32 , substr ($ wkb , $ offset , 4 ));
21852185 if ($ numRings === false ) {
2186- throw new \ RuntimeException ('Failed to unpack number of rings from WKB. ' );
2186+ throw new DatabaseException ('Failed to unpack number of rings from WKB. ' );
21872187 }
21882188
21892189 $ numRings = (int ) $ numRings [1 ];
@@ -2193,7 +2193,7 @@ public function decodePolygon(string $wkb): array
21932193 for ($ r = 0 ; $ r < $ numRings ; $ r ++) {
21942194 $ numPoints = unpack ($ uInt32 , substr ($ wkb , $ offset , 4 ));
21952195 if ($ numPoints === false ) {
2196- throw new \ RuntimeException ('Failed to unpack number of points from WKB. ' );
2196+ throw new DatabaseException ('Failed to unpack number of points from WKB. ' );
21972197 }
21982198
21992199 $ numPoints = (int ) $ numPoints [1 ];
@@ -2202,14 +2202,14 @@ public function decodePolygon(string $wkb): array
22022202 for ($ i = 0 ; $ i < $ numPoints ; $ i ++) {
22032203 $ x = unpack ($ uDouble , substr ($ wkb , $ offset , 8 ));
22042204 if ($ x === false ) {
2205- throw new \ RuntimeException ('Failed to unpack X coordinate from WKB. ' );
2205+ throw new DatabaseException ('Failed to unpack X coordinate from WKB. ' );
22062206 }
22072207
22082208 $ x = (float ) $ x [1 ];
22092209
22102210 $ y = unpack ($ uDouble , substr ($ wkb , $ offset + 8 , 8 ));
22112211 if ($ y === false ) {
2212- throw new \ RuntimeException ('Failed to unpack Y coordinate from WKB. ' );
2212+ throw new DatabaseException ('Failed to unpack Y coordinate from WKB. ' );
22132213 }
22142214
22152215 $ y = (float ) $ y [1 ];
0 commit comments