diff --git a/src/browser/browser.js b/src/browser/browser.js index 6b5c269f..6acaa4cb 100755 --- a/src/browser/browser.js +++ b/src/browser/browser.js @@ -310,7 +310,7 @@ Browser.prototype.initConfig = function() { controlSearch : true, controlSearchSrs : null, controlSearchUrl : null, - controlSearchFilter : true, + controlSearchFilter : false, controlMeasure : false, controlMeasureLite : false, controlLink : false, diff --git a/src/browser/ui/control/search-filter.js b/src/browser/ui/control/search-filter.js index 5e057468..6b9cdf5d 100644 --- a/src/browser/ui/control/search-filter.js +++ b/src/browser/ui/control/search-filter.js @@ -121,18 +121,18 @@ function nofilterSearch(data, lon, lat) { hit = hits[i]; rtrnHit = { - lat: +hit.lat, - lon: +hit.lon, - title: hit.display_name, - rank: hit.importance || 1, - country: '', - region: '', - state: '', + lat: +hit['lat'], + lon: +hit['lon'], + title: hit['title'], + rank: 1, //hit.importance || 1, + country: hit['country'], + region: hit['region'], + state: hit['state'], cc: '', type: '', - bounds: hit.boundingbox, + bounds: null, //hit.boundingbox, polygon : [], - bbox : hit.boundingbox + bbox : null //hit.boundingbox } // Calculate distance diff --git a/src/browser/ui/control/search.js b/src/browser/ui/control/search.js index 66912c7d..398f56ad 100755 --- a/src/browser/ui/control/search.js +++ b/src/browser/ui/control/search.js @@ -51,7 +51,10 @@ var UIControlSearch = function(ui, visible, visibleLock) { this.ignoreDrag = false; - this.urlTemplate = '//cdn.melown.com/vtsapi/geocode?q={value}&format=json&lang=en-US&addressdetails=1&limit=20'; + //old template '//cdn.melown.com/vtsapi/geocode?q={value}&format=json&lang=en-US&addressdetails=1&limit=20'; + //this.urlTemplate = '//cdn.melown.com/vtsapi/geocode/v3.0/{lat}/{long}/{value}'; + //this.urlTemplate = '//node.windy.com/search/v3.0/{lat}/{long}/{value}'; + this.urlTemplate = '//cdn.melown.com/vtsapi/geocode/v3.0/{lat}/{long}/{value}'; this.urlTemplate2 = this.urlTemplate; this.data = []; this.lastSearch = ''; @@ -336,10 +339,15 @@ UIControlSearch.prototype.onListLoaded = function(counter, data) { var coords = proj4(navigationSrs['srsDef'], srs, pos.getCoords()); + //check data format + if (!(data['data'] && Array.isArray(data['data']) && data['header'] && data['header']['type'] == 'search')) { + return; + } + if (this.browser.config.controlSearchFilter) { - data = filterSearch(data, coords[0], coords[1]); + data = filterSearch(data['data'], coords[0], coords[1]); } else { - data = nofilterSearch(data, coords[0], coords[1]); + data = nofilterSearch(data['data'], coords[0], coords[1]); } if (this.coords) { @@ -568,9 +576,26 @@ UIControlSearch.prototype.onChange = function() { this.hideList(); } + var map = this.browser.getMap(); + if (!map) { + return; + } + + //sort list with polygons + var pos = map.getPosition(); + var refFrame = map.getReferenceFrame(); + var navigationSrsId = refFrame['navigationSrs']; + var navigationSrs = map.getSrsInfo(navigationSrsId); + var proj4 = this.browser.getProj4(); + var srs = this.browser.config.controlSearchSrs || this.coordsSrs; + srs = this.solveSRS(srs); + + var coords = proj4(navigationSrs['srsDef'], srs, pos.getCoords()); + + this.coords = this.parseLatLon(value); - var url = this.processTemplate(this.browser.config.controlSearchUrl || this.urlTemplate, { 'value' : value }); + var url = this.processTemplate(this.browser.config.controlSearchUrl || this.urlTemplate, { 'value':value, 'lat':coords[1], 'long':coords[0] }); //console.log(url); this.searchCounter++; this.itemIndex = -1; diff --git a/src/core/core.js b/src/core/core.js index d7748f84..ff9dc55f 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -580,7 +580,7 @@ string getCoreVersion() */ function getCoreVersion(full) { - return (full ? 'Core: ' : '') + '2.22.6'; + return (full ? 'Core: ' : '') + '2.22.7'; } diff --git a/src/core/map/geodata-builder.js b/src/core/map/geodata-builder.js index 75286109..2733d468 100644 --- a/src/core/map/geodata-builder.js +++ b/src/core/map/geodata-builder.js @@ -1446,95 +1446,98 @@ MapGeodataBuilder.prototype.processHeights = function(heightsSource, precision, //var item = this.heightsProcessBuffer, lastItem; var p, res, nodeOnly, heightsLod, nodeOnly, coords, noSource; - switch (heightsSource) { - case "node-by-precision": - nodeOnly = true; - case "heightmap-by-precision": + if (item) { - coords = item.coords; + switch (heightsSource) { + case "node-by-precision": + nodeOnly = true; + case "heightmap-by-precision": - if (coords[3].srs) { - p = this.navSrs.convertCoordsFrom(coords, coords[3].srs); - } else { - p = coords; - } + coords = item.coords; - heightsLod = this.map.measure.getOptimalHeightLodBySampleSize(p, precision); - break; + if (coords[3].srs) { + p = this.navSrs.convertCoordsFrom(coords, coords[3].srs); + } else { + p = coords; + } - case "node-by-lod": - nodeOnly = true; - precision -= 8; - case "heightmap-by-lod": - heightsLod = precision; - break; - case "none": - noSource = true; - break; - } + heightsLod = this.map.measure.getOptimalHeightLodBySampleSize(p, precision); + break; + + case "node-by-lod": + nodeOnly = true; + precision -= 8; + case "heightmap-by-lod": + heightsLod = precision; + break; + case "none": + noSource = true; + break; + } - do { - coords = item.coords; + do { + coords = item.coords; - if (!noSource && coords[4] == null) { - if (coords[3].srs) { - p = this.navSrs.convertCoordsFrom(coords, coords[3].srs); - } else { - p = coords; - } + if (!noSource && coords[4] == null) { + if (coords[3].srs) { + p = this.navSrs.convertCoordsFrom(coords, coords[3].srs); + } else { + p = coords; + } - res = this.map.measure.getSpatialDivisionNode(p); + res = this.map.measure.getSpatialDivisionNode(p); - coords[4] = res[0]; - coords[5] = res[1]; + coords[4] = res[0]; + coords[5] = res[1]; - //coords[4] = p; - } + //coords[4] = p; + } - if (noSource) { - res = [0,true,true]; - } else { - res = this.map.measure.getSurfaceHeight(coords, heightsLod, null, coords[4], coords[5], null, nodeOnly); - } + if (noSource) { + res = [0,true,true]; + } else { + res = this.map.measure.getSurfaceHeight(coords, heightsLod, null, coords[4], coords[5], null, nodeOnly); + } - //res = this.map.measure.getSurfaceHeight(coords[4], heightsLod, null, null, null, null, nodeOnly); + //res = this.map.measure.getSurfaceHeight(coords[4], heightsLod, null, null, null, null, nodeOnly); - //console.log(JSON.stringify(res)); + //console.log(JSON.stringify(res)); - //if (res[1] || res[2]) { //precisin reached or not aviable - //res = this.map.measure.getSurfaceHeight(coords[4], heightsLod, null, null, null, null, nodeOnly); - //res = this.map.measure.getSurfaceHeight(coords, heightsLod, null, coords[4], coords[5], null, nodeOnly); - //} + //if (res[1] || res[2]) { //precisin reached or not aviable + //res = this.map.measure.getSurfaceHeight(coords[4], heightsLod, null, null, null, null, nodeOnly); + //res = this.map.measure.getSurfaceHeight(coords, heightsLod, null, coords[4], coords[5], null, nodeOnly); + //} - if (res[1] || res[2]) { //precision reached or not aviable + if (res[1] || res[2]) { //precision reached or not aviable - //console.log(JSON.stringify(res)); + //console.log(JSON.stringify(res)); - coords[2] += res[0]; //convet float height to fixed - this.removeFromHeightsBuffer(item, lastItem); - coords[3].heightsToProcess--; - this.heightsToProcess--; + coords[2] += res[0]; //convet float height to fixed + this.removeFromHeightsBuffer(item, lastItem); + coords[3].heightsToProcess--; + this.heightsToProcess--; - if (coords[3].heightsToProcess <= 0) { //this prevents multiple conversions - coords[3].floatHeights = false; - } + if (coords[3].heightsToProcess <= 0) { //this prevents multiple conversions + coords[3].floatHeights = false; + } - p = [coords[0], coords[1], coords[2]]; + p = [coords[0], coords[1], coords[2]]; - //console.log(JSON.stringify(p) + " srs " + coords[3].srs); + //console.log(JSON.stringify(p) + " srs " + coords[3].srs); - p = this.physSrs.convertCoordsFrom(p, coords[3].srs); + p = this.physSrs.convertCoordsFrom(p, coords[3].srs); - coords[0] = p[0]; - coords[1] = p[1]; - coords[2] = p[2]; - } + coords[0] = p[0]; + coords[1] = p[1]; + coords[2] = p[2]; + } - lastItem = item; - item = item.next; + lastItem = item; + item = item.next; - } while(item); + } while(item); + } if (this.heightsToProcess <= 0) { if (this.updateCallback) {