Giter Site home page Giter Site logo

geoconvert.js's Introduction

geoconvert.js helps a JavaScript programmer transform degree decimal-formatted latitude/longitude positions to degree/minute/second-formatted positions, from degree-decimal to UTM, and from UTM to degree-decimal.

Test code

test("qUnit tests", function() {
    var lat,
        lon,
        zone,
        utm,
        latLng,
        dmsLat,
        ddLat;
lat = 15;
lon = 15;

module("Going from DD-formatted lat/lon to UTM using WGS84 datum");
utm = new UTM(lat, lon);
equal(utm.northing, 1658325.9934411813);
equal(utm.easting, 500000);
equal(utm.lngZone, 33);
equal(utm.hemisphere, "N");

module("Going from UTM using WGS84 datum to DD-formatted lat/lon");
latLng = new LL(utm.easting, utm.northing, utm.lngZone, utm.hemisphere);
equal(latLng.longitude.toFixed(8), lat);
equal(latLng.latitude.toFixed(8), lon);

module("Going from DD-formatted lat/lon to DMS-formatted lat/lon");
dmsLat = Geoconvert.convertDDtoDMS(lat, 8);
equal(dmsLat,"15°0'0\"");

module("Going from DMS-formatted lat/lon to DD-formatted lat/lon");
ddLat = Geoconvert.convertDMStoDD("N", 15, 0, 0);
equal(ddLat, 15);

module("Blows up on out-of-range latitude");
raises(function() {
    Geoconvert.convertDMStoDD("N", 91, 0, 0);
}, "91 is outside of acceptable latitude range");

module("Blows up on out-of-range longitude");
raises(function() {
    Geoconvert.convertDMStoDD("W", -181, 0, 0);
}, "-181 is outside of acceptable longitude range");

});

geoconvert.js's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.