Geen cache-versie.

Caching uitgeschakeld. Standaardinstelling voor deze pagina:ingeschakeld (code DEF204)
Als het scherm te langzaam is, kunt u de gebruikersmodus uitschakelen om de cacheversie te bekijken.

Rechercher dans le manuel MySQL

12.16.10 Spatial Geohash Functions

Geohash is a system for encoding latitude and longitude coordinates of arbitrary precision into a text string. Geohash values are strings that contain only characters chosen from "0123456789bcdefghjkmnpqrstuvwxyz".

The functions in this section enable manipulation of geohash values, which provides applications the capabilities of importing and exporting geohash data, and of indexing and searching geohash values.

Unless otherwise specified, functions in this section handle their arguments as follows:

  • If any argument is NULL, the return value is NULL.

  • If any argument is invalid, an error occurs.

  • If any argument has a longitude or latitude that is out of range, an error occurs:

    Ranges shown are in degrees. The exact range limits deviate slightly due to floating-point arithmetic.

  • If any point argument does not have SRID 0 or 4326, an ER_SRS_NOT_FOUND error occurs. point argument SRID validity is not checked.

  • If any SRID argument refers to an undefined spatial reference system (SRS), an ER_SRS_NOT_FOUND error occurs.

  • If any SRID argument is not within the range of a 32-bit unsigned integer, an ER_DATA_OUT_OF_RANGE error occurs.

  • Otherwise, the return value is non-NULL.

These geohash functions are available:

  • ST_GeoHash(longitude, latitude, max_length), ST_GeoHash(point, max_length)

    Returns a geohash string in the connection character set and collation.

    For the first syntax, the longitude must be a number in the range [−180, 180], and the latitude must be a number in the range [−90, 90]. For the second syntax, a POINT value is required, where the X and Y coordinates are in the valid ranges for longitude and latitude, respectively.

    The resulting string is no longer than max_length characters, which has an upper limit of 100. The string might be shorter than max_length characters because the algorithm that creates the geohash value continues until it has created a string that is either an exact representation of the location or max_length characters, whichever comes first.

    ST_GeoHash() handles its arguments as described in the introduction to this section.

    1. mysql> SELECT ST_GeoHash(180,0,10), ST_GeoHash(-180,-90,15);
    2. +----------------------+-------------------------+
    3. | ST_GeoHash(180,0,10) | ST_GeoHash(-180,-90,15) |
    4. +----------------------+-------------------------+
    5. | xbpbpbpbpb           | 000000000000000         |
    6. +----------------------+-------------------------+
  • ST_LatFromGeoHash(geohash_str)

    Returns the latitude from a geohash string value, as a double-precision number in the range [−90, 90].

    The ST_LatFromGeoHash() decoding function reads no more than 433 characters from the geohash_str argument. That represents the upper limit on information in the internal representation of coordinate values. Characters past the 433rd are ignored, even if they are otherwise illegal and produce an error.

    ST_LatFromGeoHash() handles its arguments as described in the introduction to this section.

    1. mysql> SELECT ST_LatFromGeoHash(ST_GeoHash(45,-20,10));
    2. +------------------------------------------+
    3. | ST_LatFromGeoHash(ST_GeoHash(45,-20,10)) |
    4. +------------------------------------------+
    5. |                                      -20 |
    6. +------------------------------------------+
  • ST_LongFromGeoHash(geohash_str)

    Returns the longitude from a geohash string value, as a double-precision number in the range [−180, 180].

    The remarks in the description of ST_LatFromGeoHash() regarding the maximum number of characters processed from the geohash_str argument also apply to ST_LongFromGeoHash().

    ST_LongFromGeoHash() handles its arguments as described in the introduction to this section.

    1. mysql> SELECT ST_LongFromGeoHash(ST_GeoHash(45,-20,10));
    2. +-------------------------------------------+
    3. | ST_LongFromGeoHash(ST_GeoHash(45,-20,10)) |
    4. +-------------------------------------------+
    5. |                                        45 |
    6. +-------------------------------------------+
  • ST_PointFromGeoHash(geohash_str, srid)

    Returns a POINT value containing the decoded geohash value, given a geohash string value.

    The X and Y coordinates of the point are the longitude in the range [−180, 180] and the latitude in the range [−90, 90], respectively.

    The srid argument is an 32-bit unsigned integer.

    The remarks in the description of ST_LatFromGeoHash() regarding the maximum number of characters processed from the geohash_str argument also apply to ST_PointFromGeoHash().

    ST_PointFromGeoHash() handles its arguments as described in the introduction to this section.

    1. mysql> SET @gh = ST_GeoHash(45,-20,10);
    2. mysql> SELECT ST_AsText(ST_PointFromGeoHash(@gh,0));
    3. +---------------------------------------+
    4. | ST_AsText(ST_PointFromGeoHash(@gh,0)) |
    5. +---------------------------------------+
    6. | POINT(45 -20)                         |
    7. +---------------------------------------+

Zoek in de MySQL-handleiding

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 26/06/2006 gemaakt, de laatste keer de 26/10/2018 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/mysql-rf-spatial-geohash-functions.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:en Manuel MySQL : https://dev.mysql.com/

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.

Inhoudsopgave Haut