About existing packages
Dealing with geospatial data is not a new topic for Pharo community. Contributors have already worked on parsing geospatial data files, and building classes to represent and vizualise them.
Let's detail here Pharo existing packages relative to our topic, which could be useful for our project.
GeoJSON & KML parsers
GeoJSON provides a conversion from a GeoJSON file into its own geospatial data object model.
We can test it with a sample found on GitHub (here). The given GeoJSON file describes a Point, a LineString of 4 points and a Polygon (a square).
Note: coordinate reference system used by GeoJSON is the World Geodic System (WGS84). The associate map projection called Web Mercator projection, is a variant of Mercator projection and became a well-known standard for Web mapping applications. Google Maps actually uses it.
More details about GeoJSON in specification: https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.1
To parse our file, GeoJSON class implements the fromString: method which returns the associate objects of GeoJSON Pharo model.
Launch conversion in Pharo executing the following example code in playground:
This execution returns a Feature Collection object, with given features:
Adapting this GeoJSON parser to return objects based on OGC-Pharo model we're working on in this GSoC context could be interesting to provide a complete service.
After recording this file as a string in a kmlString variable, we can parse it with KMLReader class and obtain a KMLDocument:
This resulting KMLDocument has a KMLFolder which contains a collection of features with a OGCPoint, a OGCLineString and a KMLPolygon.
GitHub source: pharo-contributions/Geometry (forked from TelescopeSt)
Geometry provides a model to represent geometric elements. This package also enable elementary computations.
We can project our GIS features to this geometric model, espacially:
GPoint for our OGCPoint
GSegment for our OGCLine
GPolygon for our OGCPolygon - which also includes GTriangle for our OGCTriangle.
Let's keep in mind that this geometric model can be used if we work witha planar projection, like Mercator projection for instance.
In this case, interesting methods to perform GIS computations are: