geoapplications development http rgeo wikience org
play

Geoapplications development http://rgeo.wikience.org Higher School - PowerPoint PPT Presentation

Geoapplications development http://rgeo.wikience.org Higher School of Economics, Moscow, www.cs.hse.ru 2 Agenda 3 Binary search and DB index Index Data Index Data 1 34 2 3 2 3 3 12 3 12 5 21 4 55 1 34 5 21 4 55


  1. Geoapplications development http://rgeo.wikience.org Higher School of Economics, Moscow, www.cs.hse.ru

  2. 2 Agenda

  3. 3 Binary search and DB index Index Data Index Data 1 34 2 3 2 3 3 12 3 12 5 21 4 55 1 34 5 21 4 55 Approach 1 Approach 2 (straightforward) : (optimized) : Sequential scan, O(N) Binary search, O(log N) Drawback : slow Drawback: need to maintain index

  4. 4 Intersection problem: approach 1 Approach 1 (straightforward) : for each pair (gi, gj) compute Egenhofer matrix, if it is not empty, gi and gj intersect Drawback : slow, because operation is complex

  5. 5 Intersection problem: approach 2 Approach 2 (with MBR): 1. for each geometry gi find MBR_i 2. for each (MBR_i, MBR_j) test whether they intersect ( fast ) 3. if they do, compute Egenhofer matrix, check for intersection pattern ( slower ) Significantly reduce the need to perform step 3

  6. 6 Minimum Bounding Rectangle (MBR) http://purl.oclc.org/coordinates/a2.htm 3D case – Minimum Bounding Box (MBB) https://en.wikipedia.org/wiki/Minimum_bounding_box http://www.scriptspot.com/files/u9133/tm_bbox.png https://en.wikipedia.org/wiki/Minimum_bounding_rectangle

  7. 7 Java Topology Suite: Envelope/MBR Checks package com.vividsolutions.jts.geom; public boolean crosses(Geometry g) { // short-circuit test if (! getEnvelopeInternal().intersects(g.getEnvelopeInternal())) return false ; return relate(g).isCrosses(getDimension(), g.getDimension()); } public boolean intersects(Envelope other) { if (isNull() || other.isNull()) { return false ; } return !(other. minx > maxx || other. maxx < minx || other. miny > maxy || other. maxy < miny ); }

  8. 8 PostGIS Envelope geometry ST_Envelope (geometry g1 ); Implements : • OpenGIS Simple Features Implementation Specification for SQL 1.1. • SQL/MM specification. SQL-MM 3: 5.1.15 geometry ST_MakeEnvelope (double precision xmin , double precision ymin , double precision xmax , double precision ymax , integer srid=unknown ); Example: SELECT ST_AsText(ST_Envelope('LINESTRING(0 0, 1 3)'::geometry)); POLYGON((0 0,0 3,1 3,1 0,0 0)) http://postgis.net/docs/manual-2.2/ST_Envelope.html

  9. 9 Subset problem Approach 1 (straightforward) : Compute intersection of points/geometries with rectangle Approach 2:

  10. 10 Geohash https://en.wikipedia.org/wiki/Geohash

  11. 11 Geohash: decode example, step 1 Only 5 bits are valid (2^31 = 11111) u = 26 (decimal) = 11010 (binary) c = 11 = ‭ 01011 ‭ f = 14 = ‭ 01110 ‭ t = 25 = ‭ 11001 ‭ and so on . . . the resulting sequence of bits 11010 01011 01110 11001 . . . https://en.wikipedia.org/wiki/Geohash

  12. 12 Geohash: decode example, step 2 11010 01011 01110 11001 . . . Odd bits for lat, even bits for lon (left to right): lat = 1001101010 . . . lon = 1100111101 . . . https://en.wikipedia.org/wiki/Geohash

  13. 13 Geohash: decode example, step 3 lat = 1001101010 …, lon = 1100111101 … • • 1001101010 …

  14. 14 Geohash properties: precision source

  15. 15 Geohash properties: neighborhood

  16. 16 Geohash limitations Source

  17. 17 Geohash algorithms: filter by rectangle • • source

  18. 18 Geohash algorithms: Ngram Tree Traveral 1. Determine a “good” grid cell size with minimal overlap of grid to query shape 2. Get list of overlapping grid cells <g1, g2 , …, gN> 3. For each grid cell gi: • Seek all points with geohashes with having prefix of gi gird cell • For each point decode its geohash and intersect with query shape source

  19. 19 Geohash algorithms: filter – fixed grid depth 1. Index each point at every grid level : D, DR, DRT, DRT2, DRT2Y 2. Recursive loop across top grid cells: • If cell is within query shape, simply add all assigned documents to result • If cell intersects query shape, recursive(cell.subcells) This requires careful implementation source

  20. 20 Geohash uses GeoHash Java implementations: https://github.com/kungfoo/geohash-java https://github.com/astrapi69/jgeohash https://github.com/davidmoten/geo

  21. 21 R-Tree • Query not intersecting MBR • of a given node, cannot • intersect any of the • contained geometries •

  22. 22 R-Tree: challenges • •

  23. 23 R-Tree: one more example https://en.wikipedia.org/wiki/R-tree

  24. 24 R-Tree operations: insert • • • • •

  25. 25 R*-Tree, R+Tree https://en.wikipedia.org/wiki/R%2B_tree https://en.wikipedia.org/wiki/R*_tree

  26. 26 JTS and R-Tree • •

  27. 27 PostGIS and R-Tree http://postgis.net/docs/manual-2.2/using_postgis_dbmanagement.html#gist_indexes

  28. 28 Problem: efficient read of 2D slice from disk

  29. 29 Hilbert Curve https://en.wikipedia.org/wiki/Hilbert_curve

  30. 30 Readings • https://en.wikipedia.org/wiki/Geohash • • •

  31. 31 Practical task

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend