What it is
A small library of geometry/geography related functions. Originally made to do two things:
- calculate distance between two geographic points, using Haversine formula
- find out whether a point if within a polygon (for fleet tracking etc.)
There are also more basic functions (e.g. find out whether two lines intersect) etc.
This code is used in production by a company providing GPS fleet tracking services, so you may consider it production-ready.
How to use it
Main classes: Point, Line, Polygon, Rectangle.
Instantiate in any convenient ways (see docstrings in constructors).
Polygon.MBR(). There is also some handy magic methods, e.g. a simple statement:
point in line
tells whether the point is on the line.
intersecting(Line, Line) returns an integer denoting what the two Lines have in common (see docstring).
May be prone to errors because of floating-point arythmetics, so be aware that in some corner cases the results may be inaccurate - if you need high precision, please advise how to do it ;)
[ ] refactor into a clean class tree conformant to the OpenGIS geometry model
[ ] clean the API
[ X] add option to instantiate from WKT as returned by MySQL Spatial Extension