@prefix sioc: <http://rdfs.org/sioc/ns#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix content: <http://purl.org/rss/1.0/modules/content/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<https://lhero.org/portfolio/lh-places/>
  a sioc:Post ;
  dc:title "Spatial queries" ;
  dcterms:identifier 149923 ;
  dc:modified "2026-10-11T15:45:18Z"^^xsd:dateTime ;
  dc:created "2026-10-11T15:45:18Z"^^xsd:dateTime ;
  sioc:link <https://lhero.org/portfolio/lh-places/spatial-queries/> ;
  sioc:has_creator <https://lhero.org/author/1/#account> ;
  sioc:has_container <https://lhero.org/#posts> ;
  content:encoded """<ul class="lh_portfolio-meta"><li><strong>Part of:</strong> <a href="https://lhero.org/portfolio/lh-places/">LH Places</a></li></ul>
<p class="wp-block-paragraph">Once posts have geo_json, wp-geometa-lib lets a meta_query compare against a geometry with spatial SQL functions. The function name goes in <code>compare</code> and the other geometry, as GeoJSON, in <code>value</code>.</p>



<pre class="wp-block-code"><code>$point = '{"type":"Feature","geometry":{"type":"Point","coordinates":[144.9631,-37.8136]},"properties":{}}';

// Venues whose shape contains a point.
$q = new WP_Query( array(
    'post_type'  =&gt; 'gatherpress_venue',
    'meta_query' =&gt; array( array(
        'key'     =&gt; 'geo_json',
        'compare' =&gt; 'ST_Contains',
        'value'   =&gt; $point,
    ) ),
) );

// Posts ordered by distance from a point.
$q = new WP_Query( array(
    'post_type'  =&gt; 'post',
    'meta_query' =&gt; array( array(
        'key'     =&gt; 'geo_json',
        'compare' =&gt; 'ST_Distance_Sphere',
        'value'   =&gt; $point,
        'type'    =&gt; 'DECIMAL(10,2)',
    ) ),
    'orderby'    =&gt; 'meta_value_num',
    'order'      =&gt; 'ASC',
) );</code></pre>



<p class="wp-block-paragraph">Which functions are available depends on the database; they are the ones listed in the <code>wp_geometa_capabilities</code> option. The SRID defaults to 4326 and can be changed with the <code>wpgm_geoquery_srid</code> filter. Extra function names can be registered with <code>wpgm_known_capabilities</code>. See the upstream BrilliantPlugins/wp-geometa documentation for the full query syntax.</p>
"""^^rdf:XMLLiteral ;
  sioc:content """Part of: LH Places
Once posts have geo_json, wp-geometa-lib lets a meta_query compare against a geometry with spatial SQL functions. The function name goes in compare and the other geometry, as GeoJSON, in value.



$point = '{"type":"Feature","geometry":{"type":"Point","coordinates":[144.9631,-37.8136]},"properties":{}}';

// Venues whose shape contains a point.
$q = new WP_Query( array(
    'post_type'  =&gt; 'gatherpress_venue',
    'meta_query' =&gt; array( array(
        'key'     =&gt; 'geo_json',
        'compare' =&gt; 'ST_Contains',
        'value'   =&gt; $point,
    ) ),
) );

// Posts ordered by distance from a point.
$q = new WP_Query( array(
    'post_type'  =&gt; 'post',
    'meta_query' =&gt; array( array(
        'key'     =&gt; 'geo_json',
        'compare' =&gt; 'ST_Distance_Sphere',
        'value'   =&gt; $point,
        'type'    =&gt; 'DECIMAL(10,2)',
    ) ),
    'orderby'    =&gt; 'meta_value_num',
    'order'      =&gt; 'ASC',
) );



Which functions are available depends on the database; they are the ones listed in the wp_geometa_capabilities option. The SRID defaults to 4326 and can be changed with the wpgm_geoquery_srid filter. Extra function names can be registered with wpgm_known_capabilities. See the upstream BrilliantPlugins/wp-geometa documentation for the full query syntax.
""" ;
  sioc:topic <https://lhero.org/?taxonomy=author&term=cap-1> .

<https://lhero.org/author/1/#account> rdfs:seeAlso <https://lhero.org/author/1/?feed=lhrdf&format=turtle> .
<https://lhero.org/?taxonomy=author&term=cap-1> rdfs:seeAlso <https://lhero.org/?taxonomy=author&term=cap-1&feed=lhrdf&format=turtle> .
