Spatial
Spatial-
•
                             •
                         –
                             •
                         –
                         –
                             •
                Tessellation •
       Spatial Aggregations •
SQL 2012-                    •
•

            –
            –
            –
₪   –           •
        -       •
•
     -         DBA •
MS SQL 2000-2012 –

    Oracle 9i-11g –

 SQL Anywhere 10 –

          Sybase –
-                                •
                                 •
       Reporting Services    –
     Integration Services    –
                   Spatial   –
               PowerShell    –
    Mirroring, Replication   –
                                 •
                                 •
                                 •
GIS                   •


                           •
Y     X                –
 Y             X       –
           Y       X   –
                       –

                           •
•
–

    •
–

    •
–
DB-

                 SQL-   •
                        •
                    –
         x,y,z      –
                    –
                        •
                    –
WGS84-              –
                    –
Point           –
                                                         •
                                                         •
M-   z                  x,y                              •
         POINT(10 10) / POINT(10 10 10 1)
                                                         •


                                            Linestring       –
           LINESTRING(0 0, 10 10)                        •
                                                         •
                                                         •
                                                         •
Polygon
                                                   •
                                                   •
                                                   •

                                      Collection        –
                                                   •
                                                   •
            GeomCollection                         •
MultiPoints,MultiPolygon,MultiLineString           •
•
                                                         –STGeomFromText        •
SET @g = Geometry::STGeomFromText('LINESTRING(0 0, 10 10, 21 2)',0)
                                                               – STEnvelope     •
                                                             – STConvexHull •
                                                            – STDifference()    •
                                                           – STIntersection()   •
                                                                 – STUnion()    •
latitude- longitude -   •
                                •


WGS84    GPS
•
-   –

    –
Spatial indexes
                            •
                        –

                        –


                        –
O(n)O(logn)
•
    <>=

          •


-         •
•


Fixed quadtree           •
                 index
                         •
•
    –
•

•

    –
•
B-trees-                              SQL-     •
                    -                           •
four-level grid -       SQL-   B-
                                    hierarchy
                                                •
•
      Level                    Grid configuration        Number of cells

      Low                      4x4                       16

      Medium                   8x8

      High                     16x16                     256

                                                                                 •
•   CREATE SPATIAL INDEX SIndx_SpatialTable_geography_col3 ON
    SpatialTable2(object) WITH ( GRIDS = ( LEVEL_3 = HIGH, LEVEL_2 = HIGH ) );
Tessellation

                 •




                 •


 touched cells   •
Tessellation Rules
                                   •
                tessellation rules
                 The covering rule •
                                 –
                                 –
                                 –
                                 –
The cells-per-object rule •
The deepest-cell rule •
Spatial Aggregation
                                                                                      •
•   SELECT Geography::UnionAggregate(geog) FROM Counties WHERE name = 'Washington';




•   SELECT Geography::EnvelopeAggregate(geog) FROM Counties WHERE name = Washington';

•
•   SELECT Geography::CollectionAggregate(geog) FROM Counties WHERE name = 'Washington';




•   SELECT Geography::ConvexHullAggregate(geog) FROM Counties WHERE name = 'Washington';
SQL 2012 -
                                                    Circular Arc-          •
      – CircularString
      – CompoundCurve
      – CurvePolygon
                                                                       –

                                                                       –
DECLARE@CircularSegmentGEOGRAPHY
=GEOGRAPHY::STGeomFromText('CIRCULARSTRING(0 -30, 0 0, 0 30)',4326);
SELECT @CircularSegmentAS Shape;
Full Globe Support
                                                            SQL 2008 •


                                                                             •
    – EnvelopeAngle() method returns 180 for objects larger than a logical
      hemisphere and < 90 for smaller objects
    – ReorientObject() reverses the ring orientation


DECLARE @Globe GEOGRAPHY=GEOGRAPHY::STGeomFromText('FULLGLOBE',4326);
SELECT @Globe.STArea();-- calculate the area of the WGS84 ellipsoid
-- Result: 510,065,621,710,996 square meters
Spatial Index Enhancements
                          -                 •
                                  Auto-grid •
              GRIDS                      –
                              -          –
                                         –
                                            •
                      -                  –
                                      Hints •
•
        •
        •
-       •
        •
    -   •
SQL Explore 2012 - Aviad Deri: Spatial

SQL Explore 2012 - Aviad Deri: Spatial

  • 1.
  • 2.
  • 4.
    • – • – – • Tessellation • Spatial Aggregations • SQL 2012- •
  • 5.
    – – – ₪ – • - •
  • 6.
    - DBA • MS SQL 2000-2012 – Oracle 9i-11g – SQL Anywhere 10 – Sybase –
  • 7.
    - • • Reporting Services – Integration Services – Spatial – PowerShell – Mirroring, Replication – • • •
  • 8.
    GIS • • Y X – Y X – Y X – – •
  • 9.
    • – • – • –
  • 10.
    DB- SQL- • • – x,y,z – – • – WGS84- – –
  • 11.
    Point – • • M- z x,y • POINT(10 10) / POINT(10 10 10 1) • Linestring – LINESTRING(0 0, 10 10) • • • •
  • 12.
    Polygon • • • Collection – • • GeomCollection • MultiPoints,MultiPolygon,MultiLineString •
  • 13.
    –STGeomFromText • SET @g = Geometry::STGeomFromText('LINESTRING(0 0, 10 10, 21 2)',0) – STEnvelope • – STConvexHull • – STDifference() • – STIntersection() • – STUnion() •
  • 15.
    latitude- longitude - • • WGS84 GPS
  • 16.
    • - – –
  • 17.
    Spatial indexes • – – – O(n)O(logn)
  • 18.
    <>= • - •
  • 19.
    • Fixed quadtree • index •
  • 20.
    – • • – •
  • 21.
    B-trees- SQL- • - • four-level grid - SQL- B- hierarchy •
  • 24.
    Level Grid configuration Number of cells Low 4x4 16 Medium 8x8 High 16x16 256 • • CREATE SPATIAL INDEX SIndx_SpatialTable_geography_col3 ON SpatialTable2(object) WITH ( GRIDS = ( LEVEL_3 = HIGH, LEVEL_2 = HIGH ) );
  • 25.
    Tessellation • • touched cells •
  • 26.
    Tessellation Rules • tessellation rules The covering rule • – – – –
  • 28.
  • 29.
  • 31.
    Spatial Aggregation • • SELECT Geography::UnionAggregate(geog) FROM Counties WHERE name = 'Washington'; • SELECT Geography::EnvelopeAggregate(geog) FROM Counties WHERE name = Washington'; •
  • 32.
    SELECT Geography::CollectionAggregate(geog) FROM Counties WHERE name = 'Washington'; • SELECT Geography::ConvexHullAggregate(geog) FROM Counties WHERE name = 'Washington';
  • 33.
    SQL 2012 - Circular Arc- • – CircularString – CompoundCurve – CurvePolygon – – DECLARE@CircularSegmentGEOGRAPHY =GEOGRAPHY::STGeomFromText('CIRCULARSTRING(0 -30, 0 0, 0 30)',4326); SELECT @CircularSegmentAS Shape;
  • 34.
    Full Globe Support SQL 2008 • • – EnvelopeAngle() method returns 180 for objects larger than a logical hemisphere and < 90 for smaller objects – ReorientObject() reverses the ring orientation DECLARE @Globe GEOGRAPHY=GEOGRAPHY::STGeomFromText('FULLGLOBE',4326); SELECT @Globe.STArea();-- calculate the area of the WGS84 ellipsoid -- Result: 510,065,621,710,996 square meters
  • 35.
    Spatial Index Enhancements - • Auto-grid • GRIDS – - – – • - – Hints •
  • 36.
    • • - • • - •