Commit fbd1e076 authored by Maxym Borodenko's avatar Maxym Borodenko

Disable auto-center map

parent 9e339bd9
......@@ -43,6 +43,4 @@ public interface ElasticService {
List<String> autocompleteSearch(String query) throws SearchException;
void regenerateAccessionSequentialNumber();
String getBoundingBox(AppliedFilters filters);
}
......@@ -26,23 +26,14 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.index.query.AndFilterBuilder;
import org.elasticsearch.index.query.FilterBuilders;
import org.elasticsearch.index.query.OrFilterBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.QueryStringQueryBuilder.Operator;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.bucket.filter.Filter;
import org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder;
import org.elasticsearch.search.aggregations.metrics.max.InternalMax;
import org.elasticsearch.search.aggregations.metrics.min.InternalMin;
import org.elasticsearch.search.sort.SortBuilder;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
......@@ -83,8 +74,6 @@ import org.springframework.stereotype.Service;
@Service
public class ElasticsearchSearchServiceImpl implements ElasticService, InitializingBean {
private final ObjectMapper mapper = new ObjectMapper();
private static final Log LOG = LogFactory.getLog(ElasticsearchSearchServiceImpl.class);
@Autowired
......@@ -161,42 +150,6 @@ public class ElasticsearchSearchServiceImpl implements ElasticService, Initializ
}
}
@Override
public String getBoundingBox(final AppliedFilters filters) {
filterService.transformFiltersIfNeed(filters);
AndFilterBuilder filterBuilder = getFilterBuilder(filters);
final FilterAggregationBuilder builder = AggregationBuilders
.filter("agg").filter(filterBuilder)
.subAggregation(AggregationBuilders.min("min_longitude").field("geo.longitude"))
.subAggregation(AggregationBuilders.max("max_longitude").field("geo.longitude"))
.subAggregation(AggregationBuilders.min("min_latitude").field("geo.latitude"))
.subAggregation(AggregationBuilders.max("max_latitude").field("geo.latitude"));
SearchQuery searchQuery =
new NativeSearchQueryBuilder()
.withIndices(IndexAliasConstants.INDEXALIAS_PASSPORT_WRITE)
.withTypes(IndexAliasConstants.PASSPORT_TYPE)
.addAggregation(builder)
.build();
Aggregations aggregations = elasticsearchTemplate.query(searchQuery, SearchResponse::getAggregations);
Filter agg = aggregations.get("agg");
InternalMin minLatitude = agg.getAggregations().get("min_latitude");
InternalMin minLongitude = agg.getAggregations().get("min_longitude");
InternalMax maxLatitude = agg.getAggregations().get("max_latitude");
InternalMax maxLongitude = agg.getAggregations().get("max_longitude");
final ObjectNode geoJson = mapper.createObjectNode();
geoJson.put("west", String.valueOf(minLatitude.getValue()));
geoJson.put("south", String.valueOf(minLongitude.getValue()));
geoJson.put("east", String.valueOf(maxLatitude.getValue()));
geoJson.put("north",String.valueOf(maxLongitude.getValue()));
return geoJson.toString();
}
@Override
public TermResult termStatistics(AppliedFilters appliedFilters, String term, int size) throws SearchException {
......
......@@ -804,14 +804,6 @@ public class ExplorerController extends BaseController implements InitializingBe
return mappingService.filteredGeoJson(appliedFilters, limit);
}
@RequestMapping(value = "/explore/bounding-box", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public String getBoundingBox(@RequestParam(value = "filter", required = true) String jsonFilter) throws IOException {
AppliedFilters appliedFilters = mapper.readValue(jsonFilter, AppliedFilters.class);
return elasticService.getBoundingBox(appliedFilters);
}
@RequestMapping(value = "/explore/tile/{zoom}/{x}/{y}", produces = MediaType.IMAGE_PNG_VALUE)
public void tile(
@PathVariable("zoom") int zoom,
......
......@@ -205,10 +205,6 @@
setHeight($(this).hasClass('closed'));
});
if(JSON.stringify(jsonData) !== "{}") {
centerMap();
}
BrowseUtil.applySuggestions(jsonData, messages);
$("#panel_additional_id").hide();
......@@ -810,37 +806,9 @@
function refreshData() {
reloadTiles();
if(JSON.stringify(jsonData) !== "{}") {
centerMap();
}
refreshLinks();
}
function centerMap() {
$.ajax("<c:url value="/explore/bounding-box"/>", {
type: 'GET',
data: "filter=" + JSON.stringify(jsonData),
success: function (respObject) {
var west = respObject.west;
var south = respObject.south;
var east = respObject.east;
var north = respObject.north;
if (west == 0 && south == 0 && east == 0 && north == 0)
return;
var bounds = new GenesysMaps.BoundingBox();
bounds.add([west, south]);
bounds.add([east, north]);
map.fitBounds(bounds.getBounds());
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(textStatus);
console.log(errorThrown);
}
});
}
function applyFilters() {
var stepValue = (parseInt(localStorage.getItem("historyStep")) + 1);
localStorage.setItem("historyStep", stepValue);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment