[英]Point to latlng conversion from Google Earth KML file
Im having issue to extracting the Google Earth coordinates, because I need it to be in latlng and not GPoint, and need to expose to my Google Map app, Im aware that I can use those points to show my data in the gmap, but still need to convert to latlng, my nodejs script its 我在提取Google Earth坐标时遇到问题,因为我需要将其放置在latlng中而不是GPoint中,并且需要向我的Google Map应用公开,我知道我可以使用这些点在gmap中显示我的数据,但是需要转换为latlng,我的nodejs脚本
var fs = require('fs'),
xml2js = require('xml2js');
var parser = new xml2js.Parser();
fs.readFile(__dirname + '/doc.xml', function(err, data) {
parser.parseString(data, function (err, result) {
var data = [];
for (var i in result.data.Placemark) {
var row = result.data.Placemark[i];
var point = row.Point[0].coordinates.toString().split(',');
row = {
name : row.name[0]
, description : row.description[0]
, geolocation : [point[0], point[1]]
};
data.push(row);
}
console.log(data);
});
});
At this point Im able to extract all the data I want (I just removed all the unnecessary tags from the KML). 此时,我可以提取所需的所有数据(我刚刚从KML中删除了所有不必要的标签)。 But I need to normalize it to latlng because my other database documents (noSQL) are all in latlng.
但是我需要将其标准化为latlng,因为我的其他数据库文档(noSQL)都在latlng中。
Reverse the order of point[0] (longitude), point[1] (latitude). 颠倒点[0](经度),点[1](纬度)的顺序。
Change: 更改:
geolocation : [point[0], point[1]]
To: 至:
geolocation : [point[1], point[0]]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.