Pins Polygons & Perspectives
1
Pins Polygons and Perspectives Visualizing Geographic Data in APEX
Christoph Ruepprich Accenture Enkitec Group
Pins Polygons and Perspectives Visualizing Geographic Data in APEX - - PowerPoint PPT Presentation
Pins Polygons and Perspectives Visualizing Geographic Data in APEX Christoph Ruepprich Accenture Enkitec Group Pins Polygons & Perspectives 1 Who Am I? Dad & Husband Consultant @ Accenture an Enkitec Group DBA/Developer
Pins Polygons & Perspectives
1
Pins Polygons and Perspectives Visualizing Geographic Data in APEX
Christoph Ruepprich Accenture Enkitec Group
Pins Polygons & Perspectives
Who Am I?
2
ruepprich.wordpress.com @CRuepprich cruepprich cruepprich@enkitec.com
Pins Polygons & Perspectives
About Accenture Enkitec Group
May 2014
Oracle platform
experience
3
Pins Polygons & Perspectives
What is covered?
4
4
Pins Polygons & Perspectives
What’s Covered
5
Pins Polygons & Perspectives
First we need…
6
Turn addresses into geographic coordinates
Pins Polygons & Perspectives
Coordinates
7
Pins Polygons & Perspectives
Layers use Coordinates
8
Pins Polygons & Perspectives
Geocoding Webservices
9
Reverse Geocoding
Pins Polygons & Perspectives 10
Geocoding Webservices
Pins Polygons & Perspectives
Geocoding with
11
https://query.yahooapis.com/v1/public/yql?q=select * from geo.placefinder where text="1400 6th Ave, Seattle, WA 98101" https://query.yahooapis.com/v1/public/yql?q=select * from geo.placefinder where text="1400 6th Ave, Seattle, WA 98101"
https://query.yahooapis.com/v1/public/yql? format=json&q=select * from geo.placefinder where text="1400 6th Ave, Seattle, WA 98101" https://query.yahooapis.com/v1/public/yql? format=json&q=select * from geo.placefinder where text="1400 6th Ave, Seattle, WA 98101"
https://developer.yahoo.com/yql/guide/usage_info_limits.html
Pins Polygons & Perspectives
Geocoding with
12
Sample XML result
Pins Polygons & Perspectives
Geocoding with
13
select * from local.search where zip='76051' and query='hair cut' select * from weather.forecast where woeid=2502265
Pins Polygons & Perspectives
Geocoding with
14
http://maps.googleapis.com/maps/api/geocode/xml? sensor=false&address=1400 6th Ave, Seattle, WA 98101 http://maps.googleapis.com/maps/api/geocode/xml? sensor=false&address=1400 6th Ave, Seattle, WA 98101 json?
Pins Polygons & Perspectives
Geocoding with
15
Sample result:
Pins Polygons & Perspectives
Reverse Geocoding with
16
http://maps.googleapis.com/maps/api/geocode/xml? latlng=40.714224,-73.961452 http://maps.googleapis.com/maps/api/geocode/xml? latlng=40.714224,-73.961452 json?
Pins Polygons & Perspectives
ReverseGeocoding with
17
Pins Polygons & Perspectives
Geocoding with
18
Pins Polygons & Perspectives
Which geocoding service do I use?
19
Pins Polygons & Perspectives 20
Processing the Results
Pins Polygons & Perspectives
What to do with the results
and/or Render on map
21
Basic Steps:
Pins Polygons & Perspectives
What to do with the results
http://sourceforge.net/projects/pljson/ My Blog: http://wp.me/pRyVI-k1
22
Pins Polygons & Perspectives
23
We have coordinates.
Pins Polygons & Perspectives
Mapping with
(don’t quote me on that)
24
https://developers.google.com/maps/
Pins Polygons & Perspectives
Mapping with
25
Pins Polygons & Perspectives
Mapping with
26
https://developer.yahoo.com/maps/flash/jsGettingStarted.html https://developer.yahoo.com/maps/ajax/v2start.html
Pins Polygons & Perspectives
Mapping with
27
Pins Polygons & Perspectives
Mapping with
Location Data for Everyone - in APEX 4.2.5. What the Sample Geolocation Showcase can do for you. ODTUG Webinars
28
Pins Polygons & Perspectives
Mapping with
29
Pins Polygons & Perspectives
Mapping with
30
http://leafletjs.com/
Pins Polygons & Perspectives
Mapping with
31
Pins Polygons & Perspectives
Tile Layers with
32
http://leaflet-extras.github.io/leaflet-providers/preview/
Pins Polygons & Perspectives
API Comparisons
webmap-test.html
33
Pins Polygons & Perspectives
How to display Javascript maps
<div id=“map” style=“min-height:500px;”>
34
Pins Polygons & Perspectives
How to display Oracle maps
35
Pins Polygons & Perspectives
36
Demo Simple Map
Pins Polygons & Perspectives
37
Interacting with Map and Database
Pins Polygons & Perspectives
Interacting with the Database
38
Pins Polygons & Perspectives
Data Example
39
ID Brand Latitude Longitude 1 Shell 32.34321
2 Valero 32.15534
3 Exxon 33.92234
Gas Stations
Pins Polygons & Perspectives
Convert to JSON
40
ID Brand Latitude Longitude 1 Shell 32.34321 -97.398834 2 Valero 32.15534 -97.19984 3 Exxon 33.92234 -94.88223
Gas Stations
{ "stations":[ { "id":"1", "brand":"Shell", "lat":32.343214, "lng":-97.398834 }, { "id":"2", "brand":"Valero", "lat":32.15534, "lng":-97.19984 }, { "id":"3", "brand":"Exxon", "lat":33.92234, "lng":-94.88223 } ] }
P110_JSON Page Item:
Pins Polygons & Perspectives
Convert to JSON with PL/SQL Loop
41
for c1 in (select NAME, LAT, LNG from gas_stations) loop
… end loop;
:P110_JSON := l_json; — - For On Demand Process use
end;
Store large JSON objects in collection CLOB.
Pins Polygons & Perspectives
Loop Through JSON
42
var json = JSON.parse($v('P110_JSON')); //json contains “stations” object var gs = json.stations; for (var i=0;i<gs.length;i++){ var latlng = new L.LatLng(gs[i].lat ,gs[i].lng); var marker = L.marker(latlng); marker.addTo(map); markersArr.push(marker); }
Pins Polygons & Perspectives
Keep Track of Markers/Polygons
43
markersArr[0].lat = 123 markersArr[0].lng = 456 markersArr[1].lat = 123 markersArr[1].lng = 456
Pins Polygons & Perspectives
Remove Markers/Polygons
44
for (var i=0;i<markersArr.length;i++){ //remove markers to the map using map.removeLayer(markersArr[i]); }
Pins Polygons & Perspectives
Add Popup
45
markersArr[0].bindPopup(‘Some html text’);
Pins Polygons & Perspectives
Circles
46
Pins Polygons & Perspectives
Polygons
47
var corners =[]; corners[0] = new L.LatLng(47.65521295468833 ,-122.41790771484375); corners[1] = new L.LatLng(47.663537612601345,-122.1734619140624); corners[2] = new L.LatLng(47.56170075451973 ,-122.18719482421874); corners[3] = new L.LatLng(47.56077405523748 ,-122.43301391601562);
Pins Polygons & Perspectives
48
Demo Gas Stations
Pins Polygons & Perspectives
49
Third Party Data
Pins Polygons & Perspectives
WKT - Well Known Text
50
Pins Polygons & Perspectives
WKT - Well Known Text
51
http://en.wikipedia.org/wiki/Well-known_text
Pins Polygons & Perspectives
WKT - Well Known Text
52
http://en.wikipedia.org/wiki/Well-known_text
Pins Polygons & Perspectives
Sample Data
53
Pins Polygons & Perspectives
54
Demo Zip Codes
Pins Polygons & Perspectives
55
Finding Relationships
Pins Polygons & Perspectives
Oracle Locator/Spatial
data
Not supported with locator
56
Pins Polygons & Perspectives
Using third party WKT
Steps:
57
Pins Polygons & Perspectives
Convert WKT to SDO Geometry
58
WKT SDO Geometry
sdo_util.from_wktgeometry()
Pins Polygons & Perspectives
Zip Codes Table
59
ZIP WKT GEOM 76051 MULTIPOLYGON ((( MDSYS.SDO_GEOMETRY(2001,8307,MD SYS.SDO_POINT_TYPE(-97.094171,32.93 4568,NULL),NULL,NULL) 90210 MULTIPOLYGON ((( MDSYS.SDO_GEOMETRY(… 98101 MULTIPOLYGON ((( MDSYS.SDO_GEOMETRY(…
Pins Polygons & Perspectives
SDO_GEOMETRY
60
SDO_GEOMETRY( 2001 -- SDO_GTYPE: point ,4326 -- SDO_SRID (coordinate system) ,MDSYS.SDO_POINT_TYPE(lon, lat, NULL) -- POINT_TYPE ,NULL -- SDO_ELEM_INFO_ARRAY ,NULL -- SDO_ORDINATE_ARRAY )
Pins Polygons & Perspectives
Calculate Distance
61
select SDO_GEOM.SDO_DISTANCE( MDSYS.SDO_GEOMETRY( 2001 , 4326 , MDSYS.SDO_POINT_TYPE(1, 1, NULL) , NULL , NULL ), MDSYS.SDO_GEOMETRY( 2001 , 4326 , MDSYS.SDO_POINT_TYPE(2, 2, NULL) , NULL , NULL ) ,1 -- within 1m tolerance ,'unit=m' -- meters ) AS dist_in_meters from dual;
Pins Polygons & Perspectives
Calculate Distance
62
SELECT * FROM gas_stations g WHERE SDO_WITHIN_DISTANCE( g.geom , MDSYS.SDO_GEOMETRY( 2001 , 4326 , MDSYS.SDO_POINT_TYPE(- 97.078686, 32.939251, NULL) , NULL , NULL ) ,'distance = 5 unit=km' ) = 'TRUE'
Observer Point
Pins Polygons & Perspectives
Calculate Area
63
select SDO_GEOM.SDO_AREA( SDO_GEOMETRY( 2003 -- GTYPE: two-dimensional polygon ,4326 -- SRID ,NULL -- POINT TYPE ,SDO_ELEM_INFO_ARRAY(1,1003,1) ,SDO_ORDINATE_ARRAY(3,3, 6,3, 6,5, 4,5, 3,3) ) ,1) AREA from dual;
Pins Polygons & Perspectives
Contains
64
sdo_contains(polygon.geom,point.geom) = ‘TRUE’
Pins Polygons & Perspectives
65
Demo Contains
Pins Polygons & Perspectives
Q&A
66