+ All Categories
Home > Documents > Geoapplications development

Geoapplications development

Date post: 18-Dec-2021
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
27
Geoapplications development http://rgeo.wikience.org Higher School of Economics, Moscow, www.cs.hse.ru
Transcript
Page 1: Geoapplications development

Geoapplications development

http://rgeo.wikience.org

Higher School of Economics, Moscow, www.cs.hse.ru

Page 2: Geoapplications development

Agenda 2

Page 3: Geoapplications development

Set of core geometries 3

http://www.geopackage.org/spec/

https://en.wikipedia.org/wiki/Well-known_text

Page 4: Geoapplications development

ISO 19107 4

Following on the addition of Envelope classes, there is a tiny introduction to the most basic ISO 19107 (geometry) objects. The root of all geometric objects in ISO 19107 is GM_Object. But GeoAPI uses the Geometry name instead. There are two objects representing points in ISO 19107: • GM_Point (simply named Point in GeoAPI) is a GM_Object (GeoAPI: Geometry) sub-type. Like every

geometries, it may be relatively heavy depending on the geometry library implementation. • DirectPosition is a lightweight structure containing only ordinate values associated to a Coordinate

Reference System (CRS). DirectPosition are *not* geometries in the classes hierarchy. • In C/C++, Position is a /union/ (in the C/C++ sense) of GM_Point and DirectPosition, allowing the

same API to work with one or other type. Since unions do not exist in Java, GeoAPI simulate the union effect by defining Position as a parent interface of both Point and DirectPosition.

In ISO 19107, Envelope is simply defined by the DirectPosition of 2 corners. Like DirectPosition, Envelope is a relatively lightweight structure, not a geometry sub-type. GeoAPI and SIS define many additional methods for envelopes, but the internal structure stay lightweight: only the corner ordinate values and the CRS. http://mail-archives.apache.org/mod_mbox/sis-dev/201212.mbox/%[email protected]%3E

The base type for all types in this package is not Geometry

Page 5: Geoapplications development

LineString (Open GIS) 5

package org.opengis.geometry.coordinate; import …; /** …skipped… */ @UML(identifier="GM_LineString", specification=ISO_19107) public interface LineString extends CurveSegment { /** * Returns a sequence of positions between which the curve is linearly interpolated. * The first position in the sequence is the {@linkplain #getStartPoint start Point} * of this {@code LineString}, and the last point in the sequence is the * {@linkplain #getEndPoint end point} of this {@code LineString}. * * @return The control points between which the curve is linearly interpolated. */ @UML(identifier="controlPoint", obligation=MANDATORY, specification=ISO_19107) PointArray getControlPoints(); /** * Decomposes a line string into an equivalent sequence of line segments. * * @return The sequence of line segments. */ @UML(identifier="asGM_LineSegment", obligation=MANDATORY, specification=ISO_19107) List<LineSegment> asLineSegments(); }

org.geotools:gt-opengis:13-SNAPSHOT2

Page 6: Geoapplications development

LineString (Java Topology Suite) 6

com.vividsolutions:jts:1.132

/* ... skipped ... */

package com.vividsolutions.jts.geom;

import com.vividsolutions.jts.algorithm.CGAlgorithms;

import com.vividsolutions.jts.operation.BoundaryOp;

/**

* Models an OGC-style <code>LineString</code>.

* A LineString consists of a sequence of two or more vertices,

* ... skipped …

*/

public class LineString extends Geometry implements Lineal {

private static final long serialVersionUID = 3110669828065365560L;

/**

* The points of this <code>LineString</code>.

*/

protected CoordinateSequence points;

/* ... skipped ... */

}

Page 7: Geoapplications development

JTS TestBuilder 7

BTW, it is an example of a very good, proven software: •197 Downloads (This Week) •Last Update: 2013-05-30

For Windows just run testbuilder.bat; how to setup under MacOS: http://blog.perrygeo.net/2010/05/06/exploring-geometry/

An easy way to visualize your geometries and get feeling of operations with them

Page 8: Geoapplications development

List of operation types on geometries 8

Page 9: Geoapplications development

WKT Specification 9

Polygon Example: POLYGON ((200 300, 600 300, 600 100, 200 100, 200 300), (250 250, 350 250, 350 150, 250 150, 250 250), (400 250, 550 250, 550 200, 400 200, 400 250))

Shell

First is shell, everything next are holes

Holes

Page 10: Geoapplications development

Geometry validation 10

Q: The syntax is correct, but what really happens to this polygon? POLYGON ((10 40, 60 40, 60 10, 10 10, 10 40), (20 35, 50 35, 50 20, 20 20, 20 35), (30 30, 40 30, 40 15, 30 15, 30 30))

Answer: polygon defined incorrectly (see SPECs in readings)

Page 11: Geoapplications development

Geometry validation (2) 11

Polygon holes must not overlap with each other

Page 12: Geoapplications development

Geometry validation 12

Q: The syntax is correct, but what really happens to this polygon? POLYGON ((130 300, 400 300, 400 200, 130 200, 130 300), (300 300, 400 300, 400 200, 300 200, 300 300))

Answer: polygon defined incorrectly (see SPECs in readings)

Page 13: Geoapplications development

Geometry validation 13

Q: The syntax is correct, but what really happens to this polygon? POLYGON ((130 300, 400 300, 400 200, 130 200, 130 300), (400 270, 400 230, 310 230, 310 270, 400 270))

Answer: polygon defined incorrectly (see SPECs in readings)

Page 14: Geoapplications development

Set-oriented operations 14

https://en.wikipedia.org/wiki/DE-9IM

English Russian

Page 15: Geoapplications development

Set-oriented operations: insights 15

What is the Union result for polygons below? POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10), (20 30, 35 35, 30 20, 20 30)) POLYGON ((26.4 29.5, 30.5 30.9, 30 26, 26.4 29.5)) Result: MULTIPOLYGON (((35 10, 10 20, 15 40, 45 45, 35 10), (20 30, 30 20, 35 35, 20 30)), ((26.4 29.5, 30.5 30.9, 30 26, 26.4 29.5)))

Page 16: Geoapplications development

JTS operations on geometries 16

http://www.vividsolutions.com/jts/javadoc/com/vividsolutions/jts/geom/Geometry.html

import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryFactory; import com.vividsolutions.jts.geom.Polygon; import com.vividsolutions.jts.io.ParseException; import com.vividsolutions.jts.io.WKTReader; import org.geotools.geometry.jts.JTSFactoryFinder; GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); WKTReader reader = new WKTReader( geometryFactory ); Polygon polygonA = (Polygon) reader.read("POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10))"); Polygon polygonB = (Polygon) reader.read("POLYGON ((20 30, 35 35, 30 20, 20 30))"); Geometry result = polygonA.difference(polygonB); System.out.println(result);

Page 17: Geoapplications development

Topology 17

http://rgeo.wikience.org

Page 18: Geoapplications development

Discussion 18

GEOMETRYCOLLECTION ( POLYGON ((25 35, 35 37, 38 31, 29 25, 25 35)), LINESTRING (39 39, 30 43, 23 44), POINT (22 40), POINT (19 37), POINT (21 34), POINT (18 32), POINT (17 34), POINT (20 40)) // next slides show how to build this visually

Page 19: Geoapplications development

“closure” property 19

Polygon polygonA = (Polygon) reader.read("POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10))"); Polygon polygonB = (Polygon) reader.read("POLYGON ((20 30, 35 35, 30 20, 20 30))"); Geometry result = polygonA.difference(polygonB); // POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10), (20 30, 35 35, 30 20, 20 30)) // see course site for Java code and Maven pom.xml

Page 20: Geoapplications development

Empty features & Collections 20

GEOMETRYCOLLECTION can combine all other types

Page 21: Geoapplications development

Reprojection 21

MathTransform transform = CRS.findMathTransform(crsFeatures, crsMap, true);

geometry = JTS.transform(geometry, transform);

CoordinateReferenceSystem crs = CRS.decode("EPSG:32637"); String wkt = crs.toWKT(); System.out.println(wkt);

Page 22: Geoapplications development

Buffer 22

https://desktop.arcgis.com/en/desktop/latest/manage-data/using-sql-with-gdbs/spatial-operation-functions-for-st-geometry.htm

Geometry buffer = polygon.buffer(10); System.out.println(buffer);

Page 23: Geoapplications development

Buffer: insights 23

Page 24: Geoapplications development

Affine transformations 24

// AFFINE TRANSFORMATIONS, view results at JTS TestBuilder result.apply(AffineTransformation.rotationInstance(30)); System.out.println(result); // or several transformations at once AffineTransformation transformation = AffineTransformation.scaleInstance(2, 2). compose(AffineTransformation.rotationInstance(45)). compose(AffineTransformation.translationInstance(10, 10)); result.apply(transformation); System.out.println(result);

Page 25: Geoapplications development

Line simplification 25

http://www.caliper.com/MAPTITUDE/GPS/default.htm http://www.namekdev.net/2014/06/iterative-version-of-ramer-douglas-peucker-line-simplification-algorithm

Page 27: Geoapplications development

Recommended