Coder Social home page Coder Social logo

utm-latlng's Issues

Como utilizarla

Hola, oye necesito implementar esto en mi app Ionic 3 con mapas y quiero convertir las coordenadas LatLng a UTM. ¿Se puede aplicar esto a Ionic 3 y Angular 6?

Ademas, en este metodo: utm.convertLatLngToUtm(latitude, longitude,precision);
¿que es la precision?

Gracias.

Found a bug?

It looks like here

if ('N' === ZoneLetter) {
        NorthernHemisphere = 1;
    } else {
        NorthernHemisphere = 0;
        this.y -= 10000000.0;
    }

the this.y does not exist and the calculation fails to happen in a right way. Could you check?
I removed the this. and It looks like it worked.

Problem with UTM Zone 32

I cannot see why there is a first condition for the zone 32.

    if (LongTemp >= 8 && LongTemp <= 13 && latitude > 54.5 && latitude < 58) {
        ZoneNumber = 32;

With this code, the coordinate lat:55.0 long:12.5 returns zone 32, while other programs and converters return zone 33.
The zone exceptions are mentioned here and I cannot find anything about that condition.

Round values?

It looks like the lib is rounding the results.
In some online converters from lat/lng to UTM I got :
lat: -23.5980369
lng: -46.6808732

E = 328492.93
N = 7389267.92
Zone = 23k

but with this lib

E = 328493
N = 7389268
Zone = 23k

Would it be possible to not to round the result?

Passing zone in "utm.convertUtmToLatLng"

When passing a zone in the function convertUtmToLatLng it soesn't know if it's North hemisphere or south hemisphere. I will provide an example. If I am i coordinates (lat: 43.5216 lng:-5.6101) the conversion to UTM returns:
{ Easting: 289054.868, Northing: 4822059.711, ZoneNumber: 30, ZoneLetter: 'T' }

But if I make the conversion back with the function:
utm.convertUtmToLatLng(289054.868, 4822059.711, 30, 'T')

It gives the incorrect result:
{ lat: -46.72170894733108, lng: -5.760423230528069 }

I can only get a correct answer when i pass an "N" in the Zone parameter of "convertUtmToLatLng" function. It would be nice if this function distinguishes between zone letters that are in the North or in the South hemisphere. I think that the solution is checking the zone letter and if it is between N to Z for the North hemisphere and A to M for the south. I made the change myself in the file "UTMLatLng.js", I let it right here:

if (['N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'].indexOf(ZoneLetter) > -1) {
NorthernHemisphere = 1;
}
else {
NorthernHemisphere = 0;
y -= 10000000.0;
}

Wrong ZoneLetter

Working on a very large Angular 8 project

this.lat = 36.7201600; // Málaga, Spain
this.lng = -4.4203400; // Málaga, Spain

const precision = 4;
const to_UTM = new utmObj().convertLatLngToUtm(this.lat, this.lng, precision);

to_UTM.ZoneLetter gives me ZoneLetter as 'F' but it's actually 'S'.
Making the inverse conversion to LatLong again for Google MAPS is how I discovered the bug.

ReferenceError: ZoneNumber is not defined

Hello 👋

I have been using the utm-latlng for a few months now and I am overall very impressed by the API. However, I have recently come across an issue and I am not sure how to proceed.

When I call the function convertLatLngToUtm,

const geomPoint = featureGeom as GeoJSON.Point;
var utmCrd = this.utm.convertLatLngToUtm(geomPoint.coordinates[1], geomPoint.coordinates[0], 10);

I receive the following error:

ReferenceError: ZoneNumber is not defined

I am confused because convertLatLngToUtm does not appear to have ZoneNumber as a parameter. Please note that I am using "utm-latlng": "^1.0.6". Any suggestions would be welcomed.

Algorithm

what algorithm do you use when converting longitude / latitude to a cartesian coordinate system

Property convertLatLngToUtm does not exist on type UTMLatLng. Wrong casing in TypeScript definitions?

Seems to be some problems in the type definitions, when doing the following

import UtmObj from 'utm-latlng';

const utm = new UtmObj();
const convertedUtm = utm.convertLatLngToUtm(location.lat, location.lng, 3);  // TS problem here

Typescript complains with Property  convertLatLngToUtm does not exist on type UTMLatLng. Did you mean  ConvertLatLngToUtm ?

If we change it to utm.ConvertLatLngToUtm(...) the typescript checks passes, but later when executed it throws the following in browser console: foo.ts:48 Uncaught TypeError: utm.ConvertLatLngToUtm is not a function (debugging utm object it has lowercase c in the function name..)

Changing index.d.ts to have correct casing seems to work, but probably should be fixed in this repo also :)

Also when opening index.d.ts it also complains about the following:

  • TS7010:  Constructor , which lacks return-type annotation, implicitly has an  any  return type.
  • TS2552: Cannot find name  Zoneletter . Did you mean  ZoneLetter ?

What is precision?

Not sure if I need to specify precision to convert lon/lat to utm. TY

index.d.ts in 1.0.7 is broken

When installing 1.0.7 the index.dts is not working once in production. The file contains an error on line 61.

Constructor(type?: ElipsoidType)

ConvertLatLngToUtm(latitude: number, longitude: number, precision: number): string | {
Easting: number;
Northing: number;
ZoneNumber: number;
ZoneLetter: ZoneLetter;
}

convertUt ToLatLng(UTMEasting: number, UTMNorthing: number, UTMZoneNumber: number, UTMZoneLetter: Zoneletter): string | {
lat: number;
lng: number;
}

export = UTMLatLng;

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.