Вы находитесь на странице: 1из 53

Spatial Data in the Enterprise

Hibernate Spatial & Geolatte

ISE OV GE
Thursday 5 January 12

Karel Maesen

Who we are

Used to be a GIS-expert/consultant Works as software architect for Enterprise Systems (Vlaamse Overheid) Works on the intersection of JEE and spatial data technology Committer for Hibernate Spatial, Geolatte

&GEOVISE
Thursday 5 January 12

Agenda
Spatial data for Java programmers Persisting spatial data with Hibernate Spatial Spatial data processing with Geolatte (+ tutorial)

&GEOVISE
Thursday 5 January 12

An Introduction

Spatial data for Java

&GEOVISE
Thursday 5 January 12

spatial, geographic, geospatial, geomatics

What is spatial data?

Any data related to locations on the Earth

&GEOVISE
Thursday 5 January 12

Dening location

What is spatial data?

Locations are dened w.r.t. a spatial reference system


geographic terms or identiers (names, addresses, postal codes) coordinates of a coordinate reference system

&GEOVISE
Thursday 5 January 12

Coordinates & Coordinate Reference Systems Geographic coordinates


Latitude = angle w.r.t. equatorial plan Longitude = angle w.r.t. prime meridian Ellipsoid approximates Geoid Geoid is equipotential surface at mean sealevel

What is spatial data?

&GEOVISE
Thursday 5 January 12

Coordinates & Coordinate Reference Systems Geodetic Datum


Fixes ellipsoid to geoid

What is spatial data?

WGS84
World geodetic datum Used for GPS

Wrong datum => Errors of 50 - 500m. !! &GEOVISE


Thursday 5 January 12

Coordinates & Coordinate Reference Systems Projected coordinate system

What is spatial data?

Chose so as to preserves some aspects


Equal-Area Equi-Distant Conformal

Valid locally

Examples
Lambert 72 LAEA 3035 UTM

&GEOVISE
Thursday 5 January 12

Coordinates & Coordinate Reference Systems

What is spatial data?

Coordinate Reference Systems in practice


Identied by EPSG identier or SRID See: http://spatialreference.org/ or http://www.epsgregistry.org/

Gotchas:
Calculating with geographic coordinates Lat/Long or Long/Lat ? Google Maps -- EPSG:90093

&GEOVISE
Thursday 5 January 12

10

Geometry vs. Coverage Geometries

What is spatial data?

Discrete phenomena, well-dened boundaries Examples: streams, administrative units, roads, land plots A.k.a.: vector data

Coverage
Continuous phenomena Examples: temperature, pollution level A.k.a.: raster data

&GEOVISE
Thursday 5 January 12

11

Coverages Rectangular grid (usually)

What is spatial data?

One data value per cell Related to graphics

&GEOVISE
Thursday 5 January 12

12

Geometry

What is spatial data?

Geometry = coordinate geometry + a coordinate reference system Coordinate geometry = Lists (of lists) of coordinates describing the boundaries of the geometry

&GEOVISE
Thursday 5 January 12

13

Geometry: simple geometries

What is spatial data?

&GEOVISE
Thursday 5 January 12

14

Geometries & spatial relationships

What is spatial data?

Named topological relationships


Disjoint Intersects Touches Crosses Overlaps Within Contains

&GEOVISE
Thursday 5 January 12

15

Geometries & spatial relationships

What is spatial data?

&GEOVISE
Thursday 5 January 12

16

... And what about GIS?

&GEOVISE
Thursday 5 January 12

17

Traditional GIS

Historical Background

GIS for spatial analysis systems for research or decision-support


e.g. ESRI Arc/Info (later ArcGIS)

No standardisation, limited interoperability


e.g. Understanding GIS the Arc/Info way

Exotic: i.e. non-native to common IT-ecosystems

&GEOVISE
Thursday 5 January 12

18

Drivers for change

Historical Background

Emergence of open standards Free/Open source software


FOSS4G

2005: Google Maps showed the future Abundant spatial data


GPS, OpenStreetMap

&GEOVISE
Thursday 5 January 12

19

Beyond GIS: the emerging landscape

Historical Background

Standard-compliant service components


e.g. Web Mapping Service (ESRI, Geoserver, Deegree, Autodesk)

Spatial data capability in commodity software


Postgresql (postgis), Hibernate Spatial, JTS/Geotools/Geolatte

Cheap desktop mapping


e.g. Quantum GIS, uDIG, MapInfo

Professional GIS on the desktop


e.g. ESRI ArcGIS, GRASS (F/OSS)

&GEOVISE
Thursday 5 January 12

20

Subtitle Text

Open Standards

&GEOVISE
Thursday 5 January 12

21

ISO / TC211

Open Standards

[A]ims to establish a structured set of standards for information concerning objects or phenomena that are directly or indirectly associated with a location relative to the Earth.

ISO 19100 series standards http://www.isotc211.org/

&GEOVISE
Thursday 5 January 12

22

The OpenGeospatial Consortium (OGC)

Open Standards

The Open Geospatial Consortium (OGC) is an international industry consortium of 440 companies, government agencies and universities participating in a consensus process to develop publicly available interface standards. OGC Standards support interoperable solutions that "geoenable" the Web, wireless and location-based services and mainstream IT. The standards empower technology developers to make complex spatial information and services accessible and useful with all kinds of applications.

http://www.opengeospatial.org Collaborates closely with TC211 &GEOVISE


Thursday 5 January 12

23

Geometry standards

Open Standards

ISO 19107 - Spatial schema


Geometries in 3-dimensional space A.k.a OGC Topic 1: Feature Geometry (ISO 19107 Spatial Schema)

&GEOVISE
Thursday 5 January 12

24

&GEOVISE
Thursday 5 January 12

Geometry standards

Open Standards

OGC Simple Features Specication for SQL (SFS)


Geometry by linear interpolation between (2D-)coordinates Widely supported in databases, libraries

ISO 19125 Simple features access (SFA)


Successor to SFS A.k.a OGC Simple Feature Access

&GEOVISE
Thursday 5 January 12

26

SFS / ISO 19125 / SFA

Open Standards

&GEOVISE
Thursday 5 January 12

27

SFS / ISO 19125 / SFA Geometry methods:


Basic

Open Standards

dimension(), SRID(), envelope(), geometryType(), ...

Query
disjoint(), within(), overlaps(), relate(), ...

Analysis
distance(), buffer(), union(), ...

&GEOVISE
Thursday 5 January 12

28

SFS / ISO 19125 / SFA

Open Standards

Coordinates in 2-, 3- or 4 dimensions


X-, Y-coordinates for location in 2D Z-coordinate, typically for elevation M-coordinate for measures (SFA only)

Not real 3D, but 2.5D


Spatial operations work in the "map geometry" of the data and will therefore not reect z or m values in calculations (e.g., Equals, Length) or in generation of new geometry values (e.g., Buffer, ConvexHull, Intersection).

&GEOVISE
Thursday 5 January 12

29

M-coordinates, Measured geometries


(x1,y1,m=0) (x3,y3,m=2.5) (x2,y2,m=1.3) (x5,y5,m=4.1)

(x4,y4,m=3.2)

(x2,y2,m=2.1)

&GEOVISE
Thursday 5 January 12

30

Geometry standards & persistence

Open Standards

ISO 13249-3: SQL/MM - Part 3: Spatial Data


Originally based on the OGC Simple Features Specication for SQL, v1.1 (SFS) Denes non-simple geometries: ST_CircularString

All types and methods prexed with ST_ Also denes advanced structures: Topologies, Networks

&GEOVISE
Thursday 5 January 12

31

GeoAPI

Open Standards

Java interfaces for ISO 19100 series specications


Proposed OGC standard Very literal translation: complicated, verbose Not widely used

http://www.geoapi.org/

&GEOVISE
Thursday 5 January 12

32

Geometry data format standards

Open Standards

WKT: Well-known Text Representations for Geometry


POINT(0 1), LineString ( 10 10, 20 20, 30 40), Polygon ((10 10, 10 20, 20 20, 20 15, 10 10))

WKB: Well-known Binary Representations for Geometry ! WKT/WKB do not contain SRID, Z- or M-coordinates ! Several Extended variants
Postgis EWKT/EWKB, Sql Server

&GEOVISE
Thursday 5 January 12

33

Geometry data format standards

Open Standards

Geographic Markup Language (GML)


ISO 19136 == OGC GML (currently v3.2.1) Large, complex specication
==> implementations are often incomplete, inconsistent

SFGML: Simple Features prole, a sane subset More information: http://www.ogcnetwork.net/gml

&GEOVISE
Thursday 5 January 12

34

Geometry data format standards ESRI Shapele format

Open Standards

Open industry standard Same scope as SFA/SFS Widely used, supported by most systems

&GEOVISE
Thursday 5 January 12

35

Web service standards

Open Standards

WMS: Web Map Service (OGC)


Dynamic mapping

TMS: Tile Map Serve (informal)


Static tile maps

WFS: Web Feature Service (OGC)


Serves vector data

&GEOVISE
Thursday 5 January 12

36

Spatial Data in the DB


Postgresql / Postgis
Postgis extension Originally based on Simple features Spec. Increasingly compliant with SQL/MM Very good implementation, well-documented

MySQL
Partially compliant with SFS Spatial relations based on bounding box ! (incorrect) Read the documentation!!

&GEOVISE
Thursday 5 January 12

37

Spatial Data in the DB


Oracle 10g
SDOGEOMETRY type: proprietary, non-standard model Undocumented OGC compliance functions!

Oracle 11g
Adds ST_GEOMETRY type
SQL/MM compliant Interoperable with SDOGEOMTRY

&GEOVISE
Thursday 5 January 12

38

Spatial Data in the DB


Microsoft SQL Servers
Excellent SFS-compliant implementation Storage format publicly documented

IBM Informix
Excellent SFS-compliant implementation Storage format not publicly documented

GeoDB (H2 based)


https://github.com/jdeolive/geodb/wiki

&GEOVISE
Thursday 5 January 12

39

Geography vs. Geometry The problem

Spatial Data in the DB

SFS was intended for planar 2D geometries (projected map coordinates) What about geodetic data such as WGS84?

Geography
Like a geometry, but assumes geodetic coordinates ST_Length(), ST_Area(), ST_Distance() return meters Available in Postgis (WGS84 only) and SQL Server

&GEOVISE
Thursday 5 January 12

40

Basic libraries Java Topology Suite

Open Source Java

Implements Simple Features Specication for SQL


Limited to 2D (but can store Z-coordinates) Problematic with geodetic data (long/lat)

Many computational geometry algorithms Good quality, simple to use, very stable GEOS: port to C, used in Postgis

http://tsusiatsoftware.net/

&GEOVISE
Thursday 5 January 12

41

Basic libraries GeoTools

Open Source Java

Framework for creating GIS-applications


Referencing, Rendering, Data access, ...

Fully interoperable with JTS & versions of GeoAPI Large (sprawling) set of libraries Code of variable quality

http://www.geotools.org/

&GEOVISE
Thursday 5 January 12

42

Basic libraries Geotoolkit.org (Geotk)

Open Source Java

GeoTools fork Implements parts of GeoAPI Started as clean up and harmonization of GeoTools

http://www.geotoolkit.org

&GEOVISE
Thursday 5 January 12

43

Basic libraries Sextante

Open Source Java

Spatial data analysis library 300+ algorithms for vecor- and raster-data Interoperable with JTS

http://sextante.forge.osor.eu/

&GEOVISE
Thursday 5 January 12

44

WMS, WFS,WCS
GeoServer

Open Source Java

Most widely used WMS/WFS/WCS server Very active community

Deegree
Supports WMS, WFS, WCS, WPS Smaller community

http://www.geoserver.org/ http://www.deegree.org/ &GEOVISE


Thursday 5 January 12

45

Web Application frameworks OpenLayers

Open Source Java & JS

Most commonly used JavaScript client-framework

http://www.openlayers.org/ GeoMajas
Integrated application framework (back- & front-end) Uses GWT for client UI

http://www.geomajas.org/ &GEOVISE
Thursday 5 January 12

46

Web Application frameworks Leaet

Open Source Java & JS

Mobile web apps (esp. iOS)

http://leaet.cloudmade.com/

&GEOVISE
Thursday 5 January 12

47

Subtitle Text OSGEO

F/OSS Community

OSGeo was created to support the collaborative development of open source geospatial software, and promote its widespread use

Projects: GeoTools, GeoServer, .... FOSS4G: global conference focused on F/OSS for Geospatial

http://www.osgeo.org/

&GEOVISE
Thursday 5 January 12

48

Subtitle Text OpenStreetMap (OSM)

Open data

Global dataset (roads, admin. boundaries, rivers, ...) Community-created Creative Commons Attribution-ShareAlike 2.0 license Variable quality

http://www.openstreetmap.org/

&GEOVISE
Thursday 5 January 12

49

What does Hibernate Spatial do?

Hibernate Spatial

GeometryUserType for JTS Geometry SpatialRestrictions API HQL Spatial Functions Marshalling/unmarshalling to DB-specic formats Service Provider Interface for SpatialDialectProviders

&GEOVISE
Thursday 5 January 12

50

Subtitle Text

Hibernate Spatial

Demo

&GEOVISE
Thursday 5 January 12

51

Supported Databases

Hibernate Spatial

Oracle Spatial (SDOGEOMETRY) Postgresql/Postgis MySQL Microsoft SQL Server 2008 GeoDB (H2)

&GEOVISE
Thursday 5 January 12

52

Status HS 1.1.x

Hibernate Spatial

Supports Hibernate 3.6 Adds dwithin(), transform() methods

HS 4
Module of Hibernate Core (4.1 probably) JTS and Geolatte-geom

&GEOVISE
Thursday 5 January 12

53

Вам также может понравиться