View on GitHub

Tougo

javascript geometry and topology tools

Download this project as a .zip file Download this project as a tar.gz file

Welcome to GitHub Pages.

This is a small set of geometry tools I had written around a years ago for a small project, as well as a basic html5 renderer. I opened this repo in case I am back in the mood. As it turns out, there is plently of mood, but not adequate time. Nevertheless I do spend a few hours per week on this.

Personally I am especially proud of the removeDangles function in the topology.js file, that, for those that are not familiar with the term, it trims any line, in a line collection that does not participate in any potential line to polygon conversion.

Usage Examples

-display polygons
  1. I converted the code so that functions would no longer be global. Instead everything is packed in 4 closure functions primitives geometrical rendering topology
  2. Read Polygon Coordinates as a xy Array
    Geometries[i] ={ type : "polygon", geometry : primitives.CreatePolygon(xyArray)};
  3. Calculate the Bounding Box
    var BBox = geometrical.getBoundingBox(Geometries);
  4. Transform Polygon Coordinate to the Local Canvas System
    var tr = geometrical.transform(Geometries, BBox, Canvas_width, Canvas_height);
  5. Draw the Polygons on the Canvas Element
    rendering.drawing(tr (transformed geometries), fill (true/false), '243011'(hex color without #), canvas (the canvas object));
    rendering.drawing(tr, false, '243011', canvas);

Example Page

Map/Point in Polygon Example

Draw/Fill/Area/Centroids/Nodes Examples

Remove Dangles Example

Labeling Example

WMS on Canvas

Authors and Contributors

elasticrash

Support or Contact

You are welcome to post any comments or ideas