Rechercher dans le manuel MySQL

12.16.7.2 Point Property Functions

A Point consists of X and Y coordinates, which may be obtained using the ST_X() and ST_Y() functions, respectively. These functions also permit an optional second argument that specifies an X or Y coordinate value, in which case the function result is the Point object from the first argument with the appropriate coordinate modified to be equal to the second argument.

For Point objects that have a geographic spatial reference system (SRS), the longitude and latitude may be obtained using the ST_Longitude() and ST_Latitude() functions, respectively. These functions also permit an optional second argument that specifies a longitude or latitude value, in which case the function result is the Point object from the first argument with the longitude or latitude modified to be equal to the second argument.

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

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

  • If any geometry argument is a valid geometry but not a Point object, an ER_UNEXPECTED_GEOMETRY_TYPE error occurs.

  • If any geometry argument is not a syntactically well-formed geometry, an ER_GIS_INVALID_DATA error occurs.

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

  • If an X or Y coordinate argument is provided and the value is -inf, +inf, or NaN, an ER_DATA_OUT_OF_RANGE error occurs.

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

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

  • Otherwise, the return value is non-NULL.

These functions are available for obtaining point properties:

  • ST_Latitude(p [, new_latitude_val])

    With a single argument representing a valid Point object p that has a geographic spatial reference system (SRS), ST_Latitude() returns the latitude value of p as a double-precision number.

    With the optional second argument representing a valid latitude value, ST_Latitude() returns a Point object like the first argument with its latitude equal to the second argument.

    ST_Latitude() handles its arguments as described in the introduction to this section, with the addition that if the Point object is valid but does not have a geographic SRS, an ER_SRS_NOT_GEOGRAPHIC error occurs.

    1. mysql> SET @pt = ST_GeomFromText('POINT(45 90)', 4326);
    2. mysql> SELECT ST_Latitude(@pt);
    3. +------------------+
    4. | ST_Latitude(@pt) |
    5. +------------------+
    6. |               45 |
    7. +------------------+
    8. mysql> SELECT ST_AsText(ST_Latitude(@pt, 10));
    9. +---------------------------------+
    10. | ST_AsText(ST_Latitude(@pt, 10)) |
    11. +---------------------------------+
    12. | POINT(10 90)                    |
    13. +---------------------------------+

    This function was added in MySQL 8.0.12.

  • ST_Longitude(p [, new_longitude_val])

    With a single argument representing a valid Point object p that has a geographic spatial reference system (SRS), ST_Longitude() returns the longitude value of p as a double-precision number.

    With the optional second argument representing a valid longitude value, ST_Longitude() returns a Point object like the first argument with its longitude equal to the second argument.

    ST_Longitude() handles its arguments as described in the introduction to this section, with the addition that if the Point object is valid but does not have a geographic SRS, an ER_SRS_NOT_GEOGRAPHIC error occurs.

    1. mysql> SET @pt = ST_GeomFromText('POINT(45 90)', 4326);
    2. mysql> SELECT ST_Longitude(@pt);
    3. +-------------------+
    4. | ST_Longitude(@pt) |
    5. +-------------------+
    6. |                90 |
    7. +-------------------+
    8. mysql> SELECT ST_AsText(ST_Longitude(@pt, 10));
    9. +----------------------------------+
    10. | ST_AsText(ST_Longitude(@pt, 10)) |
    11. +----------------------------------+
    12. | POINT(45 10)                     |
    13. +----------------------------------+

    This function was added in MySQL 8.0.12.

  • ST_X(p[, new_x_val])

    With a single argument representing a valid Point object p, ST_X() returns the X-coordinate value of p as a double-precision number. As of MySQL 8.0.12, the X coordinate is considered to refer to the axis that appears first in the Point spatial reference system (SRS) definition.

    With the optional second argument, ST_X() returns a Point object like the first argument with its X coordinate equal to the second argument. As of MySQL 8.0.12, if the Point object has a geographic SRS, the second argument must be in the proper range for longitude or latitude values.

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

    1. mysql> SELECT ST_X(Point(56.7, 53.34));
    2. +--------------------------+
    3. | ST_X(Point(56.7, 53.34)) |
    4. +--------------------------+
    5. |                     56.7 |
    6. +--------------------------+
    7. mysql> SELECT ST_AsText(ST_X(Point(56.7, 53.34), 10.5));
    8. +-------------------------------------------+
    9. | ST_AsText(ST_X(Point(56.7, 53.34), 10.5)) |
    10. +-------------------------------------------+
    11. | POINT(10.5 53.34)                         |
    12. +-------------------------------------------+
  • ST_Y(p[, new_y_val])

    With a single argument representing a valid Point object p, ST_Y() returns the Y-coordinate value of p as a double-precision number. As of MySQL 8.0.12, the Y coordinate is considered to refer to the axis that appears second in the Point spatial reference system (SRS) definition.

    With the optional second argument, ST_Y() returns a Point object like the first argument with its Y coordinate equal to the second argument. As of MySQL 8.0.12, if the Point object has a geographic SRS, the second argument must be in the proper range for longitude or latitude values.

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

    1. mysql> SELECT ST_Y(Point(56.7, 53.34));
    2. +--------------------------+
    3. | ST_Y(Point(56.7, 53.34)) |
    4. +--------------------------+
    5. |                    53.34 |
    6. +--------------------------+
    7. mysql> SELECT ST_AsText(ST_Y(Point(56.7, 53.34), 10.5));
    8. +-------------------------------------------+
    9. | ST_AsText(ST_Y(Point(56.7, 53.34), 10.5)) |
    10. +-------------------------------------------+
    11. | POINT(56.7 10.5)                          |
    12. +-------------------------------------------+

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-gis-point-property-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