/geotools-js

Javascript port of geotools

Primary LanguageJavaScriptMIT LicenseMIT

Introduction

This is a javascript port of my geotools project, which was written in Java.

A jasmine based test suite is provided.

Important This project has fallen behind the Kotlin version quite a bit and I no longer maintain this. You may want to checkout the Kotlin Version, which cross compiles to Javascript via the Kotlin multiplatform support.

Features

  • GeoGeometry class with methods that allow you to:
    • Calculate distance between two coordinates using the haversine algorithm.
    • check bounding box containment for a point
    • check polygon containment for a point
    • get the center for a polygon
    • get bounding box for a polygon
    • convert circle to a polygon
    • create a polygon from a point cloud
    • translate a wgs84 coordinate by x & y meters along the latitude and longitude
  • GeoHashUtils class with methods that allow you to:
    • encode and decode geo hashes
    • check containment of a point in a geohash
    • find out the boundingbox of a geohash
    • find out neighboring geohashes east, west, south, or north of a geohash
    • get the 32 sub geo hashes for a geohash, or the north/south halves, or the NE, NW, SE, SW quarters.
    • cover lines, paths, polygons, or circles with geo hashes

Design

This library could have included a framework for defining points, lines, polygons, bounding boxes, etc. like many other libraries do. This is the main reason it doesn’t. Instead this library loosely follows the geojson conventions of using arrays. A point is represented as [latitude,longitude]. A polygon is an array of points. A bounding box is an array of [minlat,maxlat,minlon,maxlon], etc. So, this library is pretty easy to use and combine with e.g. the google maps API, which of course comes with its own constructs for these things or the Nokia maps API, which provides yet more ways to represent the same things.

Changelog & releases

There is no formal release process for this project other than ‘git push origin master’. The latest version in git that passes the provided tests should be good
enough for general use and generally there should be no reason to use something older. I’ll document major changes here.

  • port of code from java