Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...
Transcript of Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...
GeoInfo2003
Interface for spatial operations in geographical database
Karine Reis Ferreira
João Argemiro Carvalho Paiva
Gilberto Câmara
GeoInfo 2003
Summary
• Introduction – New generation of GIS and spatial DBMS
– Challenges
– TerraLib
• Goal
• API for spatial operations
– Vector and raster data
• Conclusion and future works
GeoInfo 2003
New generation of GIS
• DBMS (Database Management System) to manage spatial data [Rigaux et al, 2002]– Object-relational DBMS and spatial extension
• Transition from the monolithic systems to Spatial Information Appliances [Egenhofer, 1999] – Small GIS tailored to specific user needs
• Modular and extensible [Voisard and Schweppe,1997] – Support for addition of independent autonomous
systems
GeoInfo 2003
GIS and DBMS
• Use of DBMS to store, manipulate and manage spatial data (descriptive and geometrical data)
– Relational DBMS
� Scheme
� Binary long type (BLOB)
– Object-relational DBMS
� Spatial data types defined by spatial extensions
attributes
GGISIS
DBMS
GeoInfo 2003
Spatial Extension
• Extends object-relational DBMS for treat spatial data:
– Data Model: spatial data types (SDTs)
– Query language: operations and query on SDTs
– Spatial indexing methods (ex. R-Tree) and spatial join
• DBMS + spatial extension = Spatial DBMS
• Oracle Spatial, IBM DB2 Spatial Extender, Informix Spatial Datablade, PostGIS (PostgreSQL) and Spatial Extension in MySQL (release 4.1)
GeoInfo 2003
Spatial Extension
• Oracle Spatial
CREATE TABLE STATES (state_id NUMBER,name VARCHAR2(100)geometry MDSYS.SDO_GEOMETRY);
SELECT ES.state_idFROM STATES ES, RIVERS RIWHERE RI.gid = 234 AND
SDO_RELATE(ES.geometry, RI.geometry, ‘mask=CONTAINSquerytype=WINDOW’)= ’TRUE’;
• Oracle Spatial:
– Spatial data type: SDO_GEOMETRY
– Operators and functions
� SDO_RELATE, SDO_BUFFER, SDO_AREA
– Spatial indexing: R-Tree e QuadTree
GeoInfo 2003
Challenges
• Develop small GIS that:
– supports different DBMS, relational and object-relational
– treats the differences between spatial DBMS
– extends necessary spatial data types for geographical applications, ex. raster data
– provides spatial operations on spatial data types stored in different DBMS
GeoInfo 2003
TerraLib
• Open source GIS software library
• Provides support for the development of:
– Small GIS
� DBMS for manage spatial data
• Support for different DBMS
– Oracle, Oracle Spatial, MySQL, SQL Server, PostgreSQL
GeoInfo 2003
TerraLib
Access
TerraLib
MySQL Driver PostgreSQL Driver
TeDatabase
MySQL Oracle Spatial
PostgreSQL
ADO Driver OracleSpatial Driver
SQLServer
• Interface with DBMS
GeoInfo 2003
TerraLib
• TerraLib data model
TeDatabase
OracleSpatial DriverMySQL Driver
OracleSpatial
MySQL
createPolygonTable(tableName)
GeoInfo 2003
Goal
Development of a generic programming interface or API (Application Programming Interface) for spatial operations in geographical database in the TerraLibenvironment.
GeoInfo 2003
Challenges
• Develop small GIS that:
– supports different DBMS, relational and object-relational
– treats the differences between spatial DBMS
– extends necessary spatial data types for geographical applications, ex. raster data
– provides spatial operations on spatial data types stored in different DBMS
GeoInfo 2003
API for spatial operations
• Function set for spatial operations on geographical data stored in DBMS
• Generic API: supports relational and object-relational DBMS
• Explores spatial extension functionalities
TerraLib
API forSpatial
Operations
Oracle SpatialAccess
MySQLPostgre
SQL
DBMS
Geographic Application
Spatial Operations
Spatial Operations
GeoInfo 2003
API for spatial operations
Intersection
Union
Difference/XOr
calculateDistanceSpatialRelation
NearestNeighbors
Binary
(VD + VD)
MaskZonal-Binary
(VD + RD)
Buffer
ConvexHull
Centroid
calculateLength
calculateArea-
Unary
(VD)
SpatialScalarBoolean
VD: Vector Data RD: Raster Dada
• Vector and raster data
GeoInfo 2003
API – Vector data
DBMS
SELECT *
FROM geomTable
WHERE sigla= “MG”
calculateArea (“MG”)
blob
double Area (TePolygon poly)
TerraLib
(1)
(2)TePolygon
area
• DBMS without spatial extension – TeDatabase
(1) Get geometries from database
(2) Use TerraLib functions to compute operations
GeoInfo 2003
API – Vector data
DBMSOracle Spatial
SELECT SDO_GEOM.SDO_AREA(
geomTable, spatial_data, ...)
FROM geomTable WHERE sigla= “MG”
calculateArea (“MG”)
TerraLib
area
• DBMS with spatial extension
– Oracle Spatial Driver
� Use operators and functions of the spatial extension with SQL language
� Operations are computed by spatial DBMS
GeoInfo 2003
API – Vector data
• SpatialRelation Operation
– Returns the geographical objects which present a specific topological relation
– Topological relation [Egenhofer et al, 1994]
� TeDisjoint
� TeTouches
� TeCrosses
� TeWithin
� TeOverlap
� TeContains
� TeIntersects
� TeEquals
� TeCovers
� TeCoveredBy
GeoInfo 2003
API – Vector data
• SpatialRelation Operation
– DBMS without spatial extension
(1) Gets geometries from database based in their minimal boundary rectangle (MBR)
(2) Uses TerraLib topological functions
GeoInfo 2003
API – Vector data
• SpatialRelation Operation
– DBMS without spatial extension
(1) Gets geometries from database based in their minimal boundary rectangle (MBR)
(2) Uses TerraLib topological functions
GeoInfo 2003
API – Vector data
• SpatialRelation Operation
– Oracle Spatial Driver
� Builds a SQL query using the SDO_RELATE operator
� Operation computed by spatial extension
SELECT geomTable1.*
FROM state_polygons geomTable1,
state_polygons geomTable2
WHERE geomTable2.object_id = 'MG'
AND SDO_RELATE(geomTable1.spatial_data,
geomTable2.spatial_data,
'mask = TOUCH querytype=WINDOW')='TRUE'
GeoInfo 2003
API – Vector data
• Buffer Operation
– Generates a new geometry based on a distance to a specific geographical object
– Oracle Spatial Driver
Oracle Spatial
SELECT SDO_GEOM.SDO_BUFFER(g.spatial_data, m.diminfo, 1.0)
FROM test_Line g, USER_SDO_GEOM_METADATA m
WHERE m.table_name = 'test_Line'
AND m.column_name = 'spatial_data'
AND object_id = '17'
GeoInfo 2003
API – Vector data
• Buffer Operation
– Generates a new geometry based on a distance to a specific geographical object
– Oracle Spatial Driver
Oracle Spatial
SDO_GEOMETRY (2003, NULL, NULL,
SDO_ELEM_INFO_ARRAY (1, 1005, 8, 1, 2, 2, 5, 2, 1, ..., 9, 2, 2),
SDO_ORDINATE_ARRAY (18, 17, 19, 18, 18, 19, 16.4142136, 19,
14.7071068, 20.7071068, 14, 21, ..., 20.7071068)
GeoInfo 2003
API – Vector data
• Buffer Operation
– SDO_GEOMETRY
� Compound polygon: straight line segments (2 points) and circular arcs (3 points).
– TePolygon
� straight line segments (2 points)
GeoInfo 2003
API – Vector data
• Buffer Operation
– Generates a TePolygon from a SDO_GEOMETRY
� TeGenerateArc function
� Generates an arc through 3 points
pt1
spt3 pt2
C(x0, y0)
r� ?�
�
ptnpt1
spt3 pt2
C(x0, y0)
r� ?�
�
ptn
GeoInfo 2003
API – Raster Data
• Zonal Operation
• Calculates statistics of a region or zone of a raster data
GeoInfo 2003
API – Raster Data
• Zonal Operation
• Calculates statistics of a region or zone of a raster data
GeoInfo 2003
API – Raster Data
• Mask Operation
– Clips a raster data using a mask
GeoInfo 2003
API – Raster Data
• Mask Operation
– Clips a raster data using a mask
GeoInfo 2003
API – Raster Data
• Mask Operation
– Clips a raster data using a mask
GeoInfo 2003
API – Raster Data
• Mechanism to traverse a raster data only in a region inside or outside a specific polygon
• Developed:
– Iterator concept on TeRaster structure
� IteratorPoly
– Route strategies
GeoInfo 2003
API – Raster Data
• Iterator is an abstraction of a pointer to a sequence [Stroustrup, 1999]
• Generic programming: disconnect data structures fromalgorithms
TeCalculateStatistics(itBegin, itEnd, stat)
TeRaster::iteratorPoly itBegin = raster->begin(poly, TeBoxPiIn)
TeRaster::iteratorPoly itEnd = raster->end(poly, TeBoxPixelIn)
TeRaster* rasterData Structure
Iterator
Algorithm
GeoInfo 2003
Conclusions
• Spatial operations are essential in a geographical application
• The developed API:– Provides spatial operations on a high level of
abstraction for the developers of geographical application
– Explores a new generation of object-relational DBMS that manage geographical data
GeoInfo 2003
• Implement other operations on raster data:
– Mathematical Operations
– Reclassify
– Slice
– Weight
• Extend the API to support new spatial extensions
– Spatial Extension in MySQL (release 4.1)
• Use future resources of spatial extensions to treat raster data (ex. Oracle Spacial)
Future Works