- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/workshop-foss4g/spatial_relationships.rst
r22 r1 1 1 .. _spatial_relationships: 2 2 3 Partie 10 : relations spatiales3 Section 10: Spatial Relationships 4 4 ================================= 5 5 6 Jusqu'à maintenant nous n'avons utilisé que des fonctions qui permettent de mesurer (:command:`ST_Area`, :command:`ST_Length`), de serialiser (:command:`ST_GeomFromText`) ou désérialiser (:command:`ST_AsGML`) des géométries. Ces fonctions ont en commun de fonctionner uniquement sur une géométrie à la fois.6 So far we have only used spatial functions that measure (:command:`ST_Area`, :command:`ST_Length`), serialize (:command:`ST_GeomFromText`) or deserialize (:command:`ST_AsGML`) geometries. What these functions have in common is that they only work on one geometry at a time. 7 7 8 Les base de données spatiales sont puissantes car elle ne font pas que stoquer les géométries, elle ont aussi la faculté de vérifier les *relations entre les géométries*. 8 Spatial databases are powerful because they not only store geometry, they also have the ability to compare *relationships between geometries*. 9 9 10 Pour les questions comme "Quel est le plus proche garage à vélo prêt du park ?" ou "Ou est l'intersection du métros avec telle rue ?" nous devrons comparer les géométries représentant les garage à vélo, les rues et les lignes de métros.10 Questions like âWhich are the closet bike racks to a park?â or âWhere are the intersections of subway lines and streets?â can only be answered by comparing geometries representing the bike racks, streets, and subway lines. 11 11 12 Le standard de l'OGC définit l'ensemble suivant de fonctions pour comparer les géométries.12 The OGC standard defines the following set of methods to compare geometries. 13 13 14 14 ST_Equals 15 15 --------- 16 16 17 :command:`ST_Equals(geometry A, geometry B)` test l'égalité spatiale de deux géométries.17 :command:`ST_Equals(geometry A, geometry B)` tests the spatial equality of two geometries. 18 18 19 19 .. figure:: ./spatial_relationships/st_equals.png 20 20 :align: center 21 21 22 ST_Equals ret ourne TRUE si les deux géométries sont du même type, ont des coordonnées x.y identiques.22 ST_Equals returns TRUE if two geometries of the same type have identical x,y coordinate values, i.e. if the secondary shape is equal (identical) to the primary shape object. 23 23 24 PremiÚrement, essayons de récupérer la représentation d'un point de notre table ``nyc_subway_stations``. Nous ne prendrons que l'entrée :'Broad St'.24 First, let's retrieve a representation of a point from our ``nyc_subway_stations`` table. We'll take just the entry for 'Broad St'. 25 25 26 26 .. code-block:: sql … … 36 36 Broad St | 0101000020266900000EEBD4CF27CF2141BC17D69516315141 | POINT(583571 4506714) 37 37 38 Maintenant, copiez / collez la valeur afficher pour tester la fonction :command:`ST_Equals`:38 Then, plug the geometry representation back into an :command:`ST_Equals` test: 39 39 40 40 .. code-block:: sql … … 50 50 .. note:: 51 51 52 La représentation du point n'est pas vraiment compréhensible (``0101000020266900000EEBD4CF27CF2141BC17D69516315141``) mais c'est exactement la représentation des coordonnées. Pour tester l'égalité, utiliser ce format est nécessaire.52 The representation of the point was not very human readable (``0101000020266900000EEBD4CF27CF2141BC17D69516315141``) but it was an exact representation of the coordinate values. For a test like equality, using the exact coordinates in necessary. 53 53 54 54 55 ST_Intersects, ST_Disjoint, ST_Crosses etST_Overlaps55 ST_Intersects, ST_Disjoint, ST_Crosses and ST_Overlaps 56 56 ------------------------------------------------------ 57 57 58 :command:`ST_Intersects`, :command:`ST_Crosses`, et :command:`ST_Overlaps` test si l'intérieur des géométries s'intersect, se croise ou se chevauche.58 :command:`ST_Intersects`, :command:`ST_Crosses`, and :command:`ST_Overlaps` test whether the interiors of the geometries intersect. 59 59 60 60 .. figure:: ./spatial_relationships/st_intersects.png 61 61 :align: center 62 62 63 :command:`ST_Intersects(geometry A, geometry B)` ret ourne t (TRUE) si l'intersection ne rénvoit pas un ensemble vide de résultats. Intersects retourne le résultat exactement inverse de la fonctiondisjoint.63 :command:`ST_Intersects(geometry A, geometry B)` returns t (TRUE) if the intersection does not result in an empty set. Intersects returns the exact opposite result of disjoint. 64 64 65 65 .. figure:: ./spatial_relationships/st_disjoint.png 66 66 :align: center 67 67 68 L'opposé de ST_Intersects est :command:`ST_Disjoint(geometry A , geometry B)`. Si deux géométries sont disjointes, elle ne s'intersectent pas et vice-versa. En fait, il est souvent plus éfficace de tester si deux géométries ne s'intersectent pas que de tester si elles sont dijointes du fait que le test d'intersection peut être spatialement indexé alors que le test disjoint ne le peut pas.68 The opposite of ST_Intersects is :command:`ST_Disjoint(geometry A , geometry B)`. If two geometries are disjoint, they do not intersect, and vice-versa. In fact, it is often more efficient to test "not intersects" than to test "disjoint" because the intersects tests can be spatially indexed, while the disjoint test cannot. 69 69 70 70 .. figure:: ./spatial_relationships/st_crosses.png 71 71 :align: center 72 73 Pour les comparaisons de couples de types multipoint/polygon, multipoint/linestring, linestring/linestring, linestring/polygon, et linestring/multipolygon, :command:`ST_Crosses(geometry A, geometry B)` retourne t (TRUE) si les résultats de l'intersection74 72 75 73 For multipoint/polygon, multipoint/linestring, linestring/linestring, linestring/polygon, and linestring/multipolygon comparisons, :command:`ST_Crosses(geometry A, geometry B)` returns t (TRUE) if the intersection results in a geometry whose dimension is one less than the maximum dimension of the two source geometries and the intersection set is interior to both source geometries. … … 78 76 :align: center 79 77 80 :command:`ST_Overlaps(geometry A, geometry B)` compare deux géométries de même dimension et retourne TRUE si leur intersection est une géométrie différente des deux fournies mais de même dimension.78 :command:`ST_Overlaps(geometry A, geometry B)` compares two geometries of the same dimension and returns TRUE if their intersection set results in a geometry different from both but of the same dimension. 81 79 82 Essayons de prendre la station de métro de Broad Street et de déterminer sont voisinage en utilisant la fonction :command:`ST_Intersects`:80 Let's take our Broad Street subway station and determine its neighborhood using the :command:`ST_Intersects` function: 83 81 84 82 .. code-block:: sql … … 99 97 ---------- 100 98 101 :command:`ST_Touches` test si deux géométries se touchent en leur contour extérieur, mais leur contours intérieur ne s'intersectent pas99 :command:`ST_Touches` tests whether two geometries touch at their boundaries, but do not intersect in their interiors 102 100 103 101 .. figure:: ./spatial_relationships/st_touches.png 104 102 :align: center 105 103 106 :command:`ST_Touches(geometry A, geometry B)` ret ourn TRUE soit si les contours des géométries s'intersectent ou si l'un des contours intérieur de l'une intersecte le contour extérieur de l'autre.104 :command:`ST_Touches(geometry A, geometry B)` returns TRUE if either of the geometries' boundaries intersect or if only one of the geometry's interiors intersects the other's boundary. 107 105 108 ST_Within etST_Contains106 ST_Within and ST_Contains 109 107 ------------------------- 110 108 111 :command:`ST_Within` et :command:`ST_Contains` test si une géométrie est totalement incluse dans l'autre.109 :command:`ST_Within` and :command:`ST_Contains` test whether one geometry is fully within the other. 112 110 113 111 .. figure:: ./spatial_relationships/st_within.png 114 112 :align: center 115 113 116 :command:`ST_Within(geometry A , geometry B)` ret ourne TRUE si la premiÚre géométries est complÚtement contenue dans l'autre. ST_Within test l'exact opposé au résultat deST_Contains.114 :command:`ST_Within(geometry A , geometry B)` returns TRUE if the first geometry is completely within the second geometry. ST_Within tests for the exact opposite result of ST_Contains. 117 115 118 :command:`ST_Contains(geometry A, geometry B)` ret ourne TRUE si la seconde géométries est complÚtement contenue dans la premiÚre géométrie.116 :command:`ST_Contains(geometry A, geometry B)` returns TRUE if the second geometry is completely contained by the first geometry. 119 117 120 118 121 ST_Distance etST_DWithin119 ST_Distance and ST_DWithin 122 120 -------------------------- 123 121 124 Une question qui arrive fréquemment dans le domaine du SIG est "trouver tout les trucs qui se trouve à une distance X de cet autre truc". 122 An extremely common GIS question is "find all the stuff within distance X of this other stuff". 125 123 126 La fonction :command:`ST_Distance(geometry A, geometry B)` calcule la *plus courte* distance entre deux géoémétries. Cela est pratique pour récupérer la distance entre les objets.124 The :command:`ST_Distance(geometry A, geometry B)` calculates the *shortest* distance between two geometries and returns it as a float. This is useful for actually reporting back the distance between objects. 127 125 128 126 .. code-block:: sql … … 136 134 3 137 135 138 Pour tester si deux obets sont à la même distance d'un autre, la fonction :command:`ST_DWithin` fournit une test tirant proffit des indexes. Cela est trÚs utile pour répondre au questions du genre : "Combien d'arbre se situe dans un buffer de 500 mÚtres autour de cette route ?". Vous n'avez pas à calculer le buffer, vous avez simplement besoin de tester la distance entre les géométries.136 For testing whether two objects are within a distance of one another, the :command:`ST_DWithin` function provides an index-accelerated true/false test. This is useful for questions like "how many trees are within a 500 meter buffer of the road?". You don't have to calculate an actual buffer, you just have to test the distance relationship. 139 137 140 138 .. figure:: ./spatial_relationships/st_dwithin.png 141 139 :align: center 142 140 143 En utilisant de nouveau notre station de métros Broad Street, nous pouvons trouver les rues voisines (à 10 mÚtres de) de la station:141 Using our Broad Street subway station again, we can find the streets nearby (within 10 meters of) the subway stop: 144 142 145 143 .. code-block:: sql … … 161 159 Nassau St 162 160 163 Nous pouvons vérifier la réponse sur une carte. La station Broad St est actuellement à l'intersection des rues Wall, Broad et Nassau. 161 And we can verify the answer on a map. The Broad St station is actually at the intersection of Wall, Broad and Nassau Streets. 164 162 165 163 .. image:: ./spatial_relationships/broad_st.jpg 166 164 167 Liste des fonctions 168 ------------- ------165 Function List 166 ------------- 169 167 170 `ST_Contains(geometry A, geometry B) <http://postgis.org/docs/ST_Contains.html>`_ : retourne TRUE si aucun des points de B n'est à l'extérieur de A, et au moins un point de l'intérieur de B est à l'intérieur deA.168 `ST_Contains(geometry A, geometry B) <http://postgis.org/docs/ST_Contains.html>`_: Returns true if and only if no points of B lie in the exterior of A, and at least one point of the interior of B lies in the interior of A. 171 169 172 `ST_Crosses(geometry A, geometry B) <http://postgis.org/docs/ST_Crosses.html>`_ : retourne TRUE si la géométrie A a certains, mais pas la totalité de, ses points à l'intérieur de B.170 `ST_Crosses(geometry A, geometry B) <http://postgis.org/docs/ST_Crosses.html>`_: Returns TRUE if the supplied geometries have some, but not all, interior points in common. 173 171 174 `ST_Disjoint(geometry A , geometry B) <http://postgis.org/docs/ST_Disjoint.html>`_ : retourne TRUE si les gémétries nes s'intersectent pas - elles n'ont aucun point en commun.172 `ST_Disjoint(geometry A , geometry B) <http://postgis.org/docs/ST_Disjoint.html>`_: Returns TRUE if the Geometries do not "spatially intersect" - if they do not share any space together. 175 173 176 `ST_Distance(geometry A, geometry B) <http://postgis.org/docs/ST_Distance.html>`_ : retourne la distance cartésienne en 2 dimensions minimum entre deux géométries dans l'unité de la projection.174 `ST_Distance(geometry A, geometry B) <http://postgis.org/docs/ST_Distance.html>`_: Returns the 2-dimensional cartesian minimum distance (based on spatial ref) between two geometries in projected units. 177 175 178 `ST_DWithin(geometry A, geometry B, radius) <http://postgis.org/docs/ST_DWithin.html>`_ : retourne TRUE si les géométries sont distante (radius) l'une de l'autre.176 `ST_DWithin(geometry A, geometry B, radius) <http://postgis.org/docs/ST_DWithin.html>`_: Returns true if the geometries are within the specified distance (radius) of one another. 179 177 180 `ST_Equals(geometry A, geometry B) <http://postgis.org/docs/ST_Equals.html>`_ : retourn TRUE si les géométries fournis représentent la même géométrie. L'ordre des entités n'est pas prit en compte.178 `ST_Equals(geometry A, geometry B) <http://postgis.org/docs/ST_Equals.html>`_: Returns true if the given geometries represent the same geometry. Directionality is ignored. 181 179 182 `ST_Intersects(geometry A, geometry B) <http://postgis.org/docs/ST_Intersects.html>`_ : retourne TRUE si les géométries s'intersectent - (ont un espace en commun) et FALSE si elles n'en ont pas (elles sont disjointes).180 `ST_Intersects(geometry A, geometry B) <http://postgis.org/docs/ST_Intersects.html>`_: Returns TRUE if the Geometries/Geography "spatially intersect" - (share any portion of space) and FALSE if they don't (they are Disjoint). 183 181 184 `ST_Overlaps(geometry A, geometry B) <http://postgis.org/docs/ST_Overlaps.html>`_ : retourne TRUE si les géométries ont un espace en commun, sont de la même dimension, mais ne sont pas complÚtement contenu l'une dans l'autre.182 `ST_Overlaps(geometry A, geometry B) <http://postgis.org/docs/ST_Overlaps.html>`_: Returns TRUE if the Geometries share space, are of the same dimension, but are not completely contained by each other. 185 183 186 `ST_Touches(geometry A, geometry B) <http://postgis.org/docs/ST_Touches.html>`_ : retourne TRUE si les géométries ont au moins un point en commun, mais leur intérieurs ne s'intersectent pas.184 `ST_Touches(geometry A, geometry B) <http://postgis.org/docs/ST_Touches.html>`_: Returns TRUE if the geometries have at least one point in common, but their interiors do not intersect. 187 185 188 `ST_Within(geometry A , geometry B) <http://postgis.org/docs/ST_Within.html>`_ : retourne TRUE si la géométrie A est complÚtement à l'intérieur deB186 `ST_Within(geometry A , geometry B) <http://postgis.org/docs/ST_Within.html>`_: Returns true if the geometry A is completely inside geometry B 189 187 190 188
Note: See TracChangeset
for help on using the changeset viewer.