update geo focus map to use localName first, then label

This commit is contained in:
tworrall 2013-11-19 16:22:29 -05:00
parent 2474be9072
commit 6927e7b86d
3 changed files with 39 additions and 13 deletions

View file

@ -35,14 +35,22 @@ $(document).ready(function(){
$('a#globalLink').removeClass("selected"); $('a#globalLink').removeClass("selected");
}); });
function getLatLong(country) { function getLatLong(localName,popup) {
var lat = []; var lat = [];
latLongJson.map(function (json) { latLongJson.map(function (json) {
if ( json.name == country) { if ( json.local == localName) {
lat.push(json.data["longitude"]); lat.push(json.data["longitude"]);
lat.push(json.data["latitude"]); lat.push(json.data["latitude"]);
} }
}); });
if (lat.length == 0) {
latLongJson.map(function (json) {
if ( json.name == popup) {
lat.push(json.data["longitude"]);
lat.push(json.data["latitude"]);
}
});
}
if (lat.length == 0) { if (lat.length == 0) {
lat.push(0.0); lat.push(0.0);
lat.push(0.0); lat.push(0.0);
@ -50,23 +58,37 @@ $(document).ready(function(){
return(lat); return(lat);
} }
function getMapType(country) { function getMapType(localName,popup) {
var mt = ""; var mt = "";
latLongJson.map(function (json) { latLongJson.map(function (json) {
if ( json.name == country) { if ( json.local == localName) {
mt = json.data["mapType"]; mt = json.data["mapType"];
} }
}); });
if ( mt.length == 0 ) {
latLongJson.map(function (json) {
if ( json.name == popup) {
mt = json.data["mapType"];
}
});
}
return(mt); return(mt);
} }
function getGeoClass(country) { function getGeoClass(localName,popup) {
var gc = ""; var gc = "";
latLongJson.map(function (json) { latLongJson.map(function (json) {
if ( json.name == country) { if ( json.local == localName) {
gc = json.data["geoClass"]; gc = json.data["geoClass"];
} }
}); });
if ( gc.length == 0 ) {
latLongJson.map(function (json) {
if ( json.name == popup) {
gc = json.data["geoClass"];
}
});
}
return(gc); return(gc);
} }
@ -342,7 +364,6 @@ $(document).ready(function(){
action: "getGeoFocusLocations", action: "getGeoFocusLocations",
}, },
complete: function(xhr, status) { complete: function(xhr, status) {
var results = $.parseJSON(xhr.responseText); var results = $.parseJSON(xhr.responseText);
if ( results.length == 0 ) { if ( results.length == 0 ) {
var html = i18nStrings.currentlyNoResearchers; var html = i18nStrings.currentlyNoResearchers;
@ -355,10 +376,11 @@ $(document).ready(function(){
} }
else { else {
$.each(results, function() { $.each(results, function() {
var locale = this.properties.popupContent; var popup = this.properties.popupContent;
this.geometry.coordinates = getLatLong(locale); var localName = this.properties.local;
this.properties.mapType = getMapType(locale); this.geometry.coordinates = getLatLong(localName,popup);
this.properties.geoClass = getGeoClass(locale); this.properties.mapType = getMapType(localName,popup);
this.properties.geoClass = getGeoClass(localName,popup);
researchAreas["features"].push(this); researchAreas["features"].push(this);
}); });
buildGlobalMap(); buildGlobalMap();

File diff suppressed because one or more lines are too long

View file

@ -36,7 +36,8 @@ public class GeoFocusMapLocations extends AbstractAjaxResponder {
+ "PREFIX core: <http://vivoweb.org/ontology/core#> \n" + "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
+ "PREFIX foaf: <http://xmlns.com/foaf/0.1/> \n" + "PREFIX foaf: <http://xmlns.com/foaf/0.1/> \n"
+ "PREFIX vivoc: <http://vivo.library.cornell.edu/ns/0.1#> \n" + "PREFIX vivoc: <http://vivo.library.cornell.edu/ns/0.1#> \n"
+ "SELECT DISTINCT ?label ?location (COUNT(DISTINCT ?person) AS ?count) \n" + "PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> "
+ "SELECT DISTINCT ?label ?location (afn:localname(?location) AS ?localName) (COUNT(DISTINCT ?person) AS ?count) \n"
+ "WHERE { { \n" + "WHERE { { \n"
+ " ?location rdf:type core:GeographicRegion . \n" + " ?location rdf:type core:GeographicRegion . \n"
+ " ?location rdfs:label ?label . \n" + " ?location rdfs:label ?label . \n"
@ -77,6 +78,7 @@ public class GeoFocusMapLocations extends AbstractAjaxResponder {
String label = map.get("label"); String label = map.get("label");
String html = map.get("count"); String html = map.get("count");
String uri = map.get("location"); String uri = map.get("location");
String local = map.get("localName");
if ( uri != null ) { if ( uri != null ) {
uri = UrlBuilder.urlEncode(uri); uri = UrlBuilder.urlEncode(uri);
} }
@ -107,6 +109,8 @@ public class GeoFocusMapLocations extends AbstractAjaxResponder {
+ radius + radius
+ ",\"uri\": \"" + ",\"uri\": \""
+ uri + uri
+ "\",\"local\": \""
+ local
+ "\"}},"; + "\"}},";
response += tempStr; response += tempStr;
previousLabel = label; previousLabel = label;