Skip to content

Commit

Permalink
add LineString and Point into capability list
Browse files Browse the repository at this point in the history
  • Loading branch information
laiconsulting committed Mar 20, 2023
1 parent eedaec4 commit 8ce337c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Binary file modified .DS_Store
Binary file not shown.
8 changes: 4 additions & 4 deletions wp-geoutil.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,8 @@ public static function metaval_to_geom( $metaval = false, $force_multi = false )
if ( $force_multi && false === strpos( $wkt, 'MULTI' ) ) {
if ( 0 === strpos( $wkt, 'POINT' ) ) {
$wkt = preg_replace( '@^POINT@','MULTIPOINT', $wkt );
} else if ( 0 === strpos( $wkt, 'LINESTRING' ) || 0 === strpos( $wkt, 'POLYGON' ) ) {
$wkt = preg_replace( '@^(LINESTRING|POLYGON)(\s*)(\(.*?\)[^,])@','MULTI$1$2($3)', $wkt );
} else if ( 0 === strpos( $wkt, 'LINE' ) || 0 === strpos( $wkt, 'POLYGON' ) ) {
$wkt = preg_replace( '@^(LINE|POLYGON)(\s*)(\(.*?\)[^,])@','MULTI$1$2($3)', $wkt );
}
}

Expand Down Expand Up @@ -705,7 +705,7 @@ public static function get_srid() {
* @param array $arguments The arguments for the function.
*/
public static function __callStatic( $name, $arguments ) {
if ( in_array( strtolower( $name ), self::get_capabilities(), true ) ) {
if ( in_array( strtolower( $name ),array_merge( self::get_capabilities(),array("linestring","point")), true ) ) {
return self::run_spatial_query( $name, $arguments );
}
}
Expand Down Expand Up @@ -739,7 +739,7 @@ private static function run_spatial_query( $name, $arguments = array() ) {
$maybe_geom = self::metaval_to_geom( $arg );
if ( false !== $maybe_geom ) {
$arguments[ $idx ] = $maybe_geom;
$q .= 'ST_GeomFromText(%s)';
$q .= 'ST_GeomCollFromText(%s)';
} else {
$q .= '%s';
}
Expand Down

0 comments on commit 8ce337c

Please sign in to comment.