mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
change geoJson property rectangels to latLng
prevent the need for constant calls to reverse in the map and marker code. note that the feature geometry is still in the lngLat format per the geoJson format rules
This commit is contained in:
parent
d3f6028e1b
commit
b4c0a68592
6 changed files with 23 additions and 30 deletions
|
@ -17,29 +17,39 @@ define(function (require) {
|
|||
if (!geohash) return;
|
||||
|
||||
var location = decodeGeoHash(geohash);
|
||||
var center = [
|
||||
|
||||
var centerLatLng = [
|
||||
location.latitude[2],
|
||||
location.longitude[2]
|
||||
];
|
||||
|
||||
// geoJson coords use LngLat coordinates
|
||||
// http://geojson.org/geojson-spec.html#positions
|
||||
// "longitude, latitude, altitude for coordinates in a geographic coordinate reference system"
|
||||
var centerLngLat = [
|
||||
location.longitude[2],
|
||||
location.latitude[2]
|
||||
];
|
||||
|
||||
var rectangle = [
|
||||
[location.longitude[0], location.latitude[0]],
|
||||
[location.longitude[1], location.latitude[0]],
|
||||
[location.longitude[1], location.latitude[1]],
|
||||
[location.longitude[0], location.latitude[1]]
|
||||
[location.latitude[0], location.longitude[0]],
|
||||
[location.latitude[0], location.longitude[1]],
|
||||
[location.latitude[1], location.longitude[1]],
|
||||
[location.latitude[1], location.longitude[0]],
|
||||
];
|
||||
|
||||
|
||||
features.push({
|
||||
type: 'Feature',
|
||||
geometry: {
|
||||
type: 'Point',
|
||||
coordinates: center
|
||||
coordinates: centerLngLat
|
||||
},
|
||||
properties: {
|
||||
geohash: geohash,
|
||||
value: unwrap(row[metricI]),
|
||||
aggConfigResult: getAcr(row[metricI]),
|
||||
center: center,
|
||||
center: centerLatLng,
|
||||
rectangle: rectangle
|
||||
}
|
||||
});
|
||||
|
|
|
@ -299,14 +299,7 @@ define(function (require) {
|
|||
*/
|
||||
Map.prototype._getDataRectangles = function () {
|
||||
if (!this._geoJson) return [];
|
||||
|
||||
return _(this._geoJson.features)
|
||||
.pluck('properties.rectangle')
|
||||
.invoke('map', function (rectangle) {
|
||||
// turn around the LngLat recieved from ES into LatLng for leaflet
|
||||
return rectangle.slice(0).reverse();
|
||||
})
|
||||
.value();
|
||||
return _.pluck(this._geoJson.features, 'properties.rectangle');
|
||||
};
|
||||
|
||||
return Map;
|
||||
|
|
|
@ -189,11 +189,7 @@ define(function (require) {
|
|||
var self = this;
|
||||
return function (feature) {
|
||||
var mapBounds = self.map.getBounds();
|
||||
var bucketRectBounds = feature.properties.rectangle.map(function (rect) {
|
||||
// turn around the LngLat recieved from ES into LatLng for leaflet
|
||||
return rect.slice(0).reverse();
|
||||
});
|
||||
|
||||
var bucketRectBounds = _.get(feature, 'properties.rectangle');
|
||||
return mapBounds.intersects(bucketRectBounds);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -27,8 +27,8 @@ define(function (require) {
|
|||
// get bounds from northEast[3] and southWest[1]
|
||||
// corners in geohash rectangle
|
||||
var corners = [
|
||||
[geohashRect[3][1], geohashRect[3][0]],
|
||||
[geohashRect[1][1], geohashRect[1][0]]
|
||||
[geohashRect[3][0], geohashRect[3][1]],
|
||||
[geohashRect[1][0], geohashRect[1][1]]
|
||||
];
|
||||
return L.rectangle(corners);
|
||||
}
|
||||
|
|
|
@ -182,8 +182,8 @@ define(function (require) {
|
|||
var mapData = this.geoJson;
|
||||
|
||||
return this.geoJson.features.map(function (feature) {
|
||||
var lat = feature.geometry.coordinates[1];
|
||||
var lng = feature.geometry.coordinates[0];
|
||||
var lat = feature.properties.center[0];
|
||||
var lng = feature.properties.center[1];
|
||||
var heatIntensity;
|
||||
|
||||
if (!self._attr.heatNormalizeData) {
|
||||
|
|
|
@ -7,12 +7,6 @@ define(function (require) {
|
|||
var Chart = Private(require('components/vislib/visualizations/_chart'));
|
||||
var Map = Private(require('components/vislib/visualizations/_map'));
|
||||
|
||||
// Convenience function to turn around the LngLat recieved from ES
|
||||
function cloneAndReverse(arr) {
|
||||
var l = arr.length;
|
||||
return arr.map(function (curr, idx) { return arr[l - (idx + 1)]; });
|
||||
}
|
||||
|
||||
/**
|
||||
* Tile Map Visualization: renders maps
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue