shahid28 / utm-latlng Goto Github PK
View Code? Open in Web Editor NEWLatLng to UTM converter vice versa
License: MIT License
LatLng to UTM converter vice versa
License: MIT License
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.
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.
Can you please add a description of precision
argument of utm.convertLatLngToUtm()
to the README?
I think it's the precision in meters?
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.
Stupid question but how do I do this in typescript
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?
var M is not being properly declared in Line 126 of UTMLatLng.js file
it is
M = y / 0.9996;
should be
var M = y / 0.9996;
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;
}
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.
Please consider adding a LICENSE
file to the repository, and referencing it in the package.json
file. Without a license, it is ambiguous whether and how others are allowed to use this code.
Thanks!
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.
what algorithm do you use when converting longitude / latitude to a cartesian coordinate system
Please review here - https://stackoverflow.com/questions/61310642/utm-latlng-module-hemisphere-option
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 ?
Not sure if I need to specify precision to convert lon/lat to utm. TY
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;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.