Updates Map to East Coast: query, coordinate mappings
diff --git a/asterix-examples/src/main/resources/black-cherry/run_black_cherry.py b/asterix-examples/src/main/resources/black-cherry/run_black_cherry.py
index 682339e..a7af311 100755
--- a/asterix-examples/src/main/resources/black-cherry/run_black_cherry.py
+++ b/asterix-examples/src/main/resources/black-cherry/run_black_cherry.py
@@ -18,7 +18,10 @@
def build_response(endpoint, data):
api_endpoint = "http://localhost:19002/" + endpoint
response = requests.get(api_endpoint, params=data, headers=http_header)
- return response.json()
+ try:
+ return response.json();
+ except ValueError:
+ return []
# API Endpoints
@route('/query')
diff --git a/asterix-examples/src/main/resources/black-cherry/static/data/query.txt b/asterix-examples/src/main/resources/black-cherry/static/data/query.txt
index 959a264..f577c52 100755
--- a/asterix-examples/src/main/resources/black-cherry/static/data/query.txt
+++ b/asterix-examples/src/main/resources/black-cherry/static/data/query.txt
@@ -28,5 +28,20 @@
create dataset TweetMessages(TweetMessageType)
primary key tweetid;
+create dataset TweetMessagesShifted(TweetMessageType)
+primary key tweetid;
+
load dataset TweetMessages using localfs
(("path"="localhost://FULL_PATH/twm.adm"),("format"="adm"));
+
+insert into dataset TweetMessagesShifted
+(
+for $t in dataset TweetMessages return {
+ "tweetid" : $t.tweetid,
+ "user" : $t.user,
+ "sender-location" : create-point(get-x($t.sender-location), -1*get-y($t.sender-location)),
+ "send-time" : $t.send-time,
+ "referred-topics": $t.referred-topics,
+ "message-text": $t.message-text
+}
+);
diff --git a/asterix-examples/src/main/resources/black-cherry/static/js/cherry.js b/asterix-examples/src/main/resources/black-cherry/static/js/cherry.js
index 83c5ab2..788fd1f 100755
--- a/asterix-examples/src/main/resources/black-cherry/static/js/cherry.js
+++ b/asterix-examples/src/main/resources/black-cherry/static/js/cherry.js
@@ -24,12 +24,9 @@
// UI Elements - A button to clear current map and query data
$("#clear-button").button().click(function () {
- mapWidgetClearMap();
+ mapWidgetResetMap();
param_placeholder = {};
- map.setZoom(4);
- map.setCenter(new google.maps.LatLng(38.89, 77.03));
-
$('#query-preview-window').html('');
$("#metatweetzone").html('');
});
@@ -98,9 +95,9 @@
// UI Elements - Creates map and location auto-complete
onOpenExploreMap();
var mapOptions = {
- center: new google.maps.LatLng(38.89, 77.03),
+ center: new google.maps.LatLng(38.89, -77.03),
zoom: 4,
- mapTypeId: google.maps.MapTypeId.ROADMAP, // Could also be SATELLITE
+ mapTypeId: google.maps.MapTypeId.ROADMAP,
streetViewControl: false,
draggable : false
};
@@ -194,7 +191,7 @@
// UI Element - Query Submission
$("#submit-button").button().click(function () {
// Clear current map on trigger
- mapWidgetClearMap();
+
// gather all of the data from the inputs
var kwterm = $("#keyword-textbox").val();
@@ -257,11 +254,16 @@
function buildAQLQueryFromForm(parameters) {
+
+ // GEOFIX: Longitude needs to be in negative coordinates for the adjusted dataset.
var bounds = {
- "ne" : { "lat" : parameters["neLat"], "lng" : parameters["neLng"]},
- "sw" : { "lat" : parameters["swLat"], "lng" : parameters["swLng"]}
+ "ne" : { "lat" : parameters["neLat"], "lng" : -1*parameters["neLng"]},
+ "sw" : { "lat" : parameters["swLat"], "lng" : -1*parameters["swLng"]}
};
+ alert("NE: " + bounds["ne"]["lat"] + ", " + bounds["ne"]["lng"] +
+ "\nSW: " + bounds["sw"]["lat"] + ", " + bounds["sw"]["lng"]);
+
var rectangle =
new FunctionExpression("create-rectangle",
new FunctionExpression("create-point", bounds["sw"]["lat"], bounds["sw"]["lng"]),
@@ -269,7 +271,7 @@
var aql = new FLWOGRExpression()
- .ForClause("$t", new AExpression("dataset TweetMessages"))
+ .ForClause("$t", new AExpression("dataset TweetMessagesShifted"))
.LetClause("$keyword", new AExpression('"' + parameters["keyword"] + '"'))
.LetClause("$region", rectangle)
.WhereClause().and(
@@ -480,13 +482,9 @@
};
var map_circle = new google.maps.Circle(map_circle_options);
map_circle.val = mapPlotData[m];
- /*var map_circle_info = new google.maps.InfoWindow({
- content: mapPlotData[m].weight + " "
- });*/
-
+
// Clicking on a circle drills down map to that value
google.maps.event.addListener(map_circle, 'click', function (event) {
-
onMapPointDrillDown(map_circle.val);
});
@@ -555,7 +553,7 @@
new FunctionExpression("create-point", bounds["ne"]["lat"], bounds["ne"]["lng"]));
var drillDown = new FLWOGRExpression()
- .ForClause("$t", new AExpression("dataset TweetMessages"))
+ .ForClause("$t", new AExpression("dataset TweetMessagesShifted"))
.LetClause("$keyword", new AExpression('"' + parameters["keyword"] + '"'))
.LetClause("$region", zoomRectangle)
.WhereClause().and(
@@ -739,6 +737,7 @@
onDropTweetBook(tweetbook)
});
+ //FIXME Why is this commented out?
/*.success(onTweetbookQuerySuccessPlot, true)
.add_extra("on_click_marker", onClickTweetbookMapMarker)
.add_extra("on_clean_result", onCleanPlotTweetbook)*/
@@ -747,7 +746,7 @@
function onPlotTweetbook(tweetbook) {
var plotTweetQuery = new FLWOGRExpression()
- .ForClause("$t", new AExpression("dataset TweetMessages"))
+ .ForClause("$t", new AExpression("dataset TweetMessagesShifted"))
.ForClause("$m", new AExpression("dataset " + tweetbook))
.WhereClause(new AExpression("$m.tweetid = $t.tweetid"))
.ReturnClause({
@@ -979,14 +978,25 @@
}
/**
-* Clears map elements - legend, plotted items, overlays
+* Clears ALL map elements - legend, plotted items, overlays
*/
-function mapWidgetClearMap() {
+function mapWidgetResetMap() {
if (selectionRect) {
selectionRect.setMap(null);
selectionRect = null;
}
+
+ mapWidgetClearMap();
+
+ // Reset map center and zoom
+ map.setCenter(new google.maps.LatLng(38.89, -77.03));
+ map.setZoom(4);
+}
+
+function mapWidgetClearMap() {
+
+ // Remove previously plotted data/markers
for (c in map_cells) {
map_cells[c].setMap(null);
}
@@ -995,13 +1005,9 @@
map_tweet_markers[m].setMap(null);
}
map_tweet_markers = [];
-
+
// Remove legend from map
map.controls[google.maps.ControlPosition.LEFT_BOTTOM].clear();
-
- // Reset map center and zoom
- map.setCenter(new google.maps.LatLng(38.89, 77.03));
- map.setZoom(4);
}
/**