Modifications to Cherry Demo - update syntax
diff --git a/asterix-examples/src/main/resources/old/css/bootstrap-responsive.css b/asterix-examples/src/main/resources/cherry/css/bootstrap-responsive.css
similarity index 100%
rename from asterix-examples/src/main/resources/old/css/bootstrap-responsive.css
rename to asterix-examples/src/main/resources/cherry/css/bootstrap-responsive.css
diff --git a/asterix-examples/src/main/resources/old/css/bootstrap-responsive.min.css b/asterix-examples/src/main/resources/cherry/css/bootstrap-responsive.min.css
similarity index 100%
rename from asterix-examples/src/main/resources/old/css/bootstrap-responsive.min.css
rename to asterix-examples/src/main/resources/cherry/css/bootstrap-responsive.min.css
diff --git a/asterix-examples/src/main/resources/old/css/bootstrap.css b/asterix-examples/src/main/resources/cherry/css/bootstrap.css
similarity index 100%
rename from asterix-examples/src/main/resources/old/css/bootstrap.css
rename to asterix-examples/src/main/resources/cherry/css/bootstrap.css
diff --git a/asterix-examples/src/main/resources/old/css/bootstrap.min.css b/asterix-examples/src/main/resources/cherry/css/bootstrap.min.css
similarity index 100%
rename from asterix-examples/src/main/resources/old/css/bootstrap.min.css
rename to asterix-examples/src/main/resources/cherry/css/bootstrap.min.css
diff --git a/asterix-examples/src/main/resources/old/css/jquery.dataTables.css b/asterix-examples/src/main/resources/cherry/css/jquery.dataTables.css
similarity index 100%
rename from asterix-examples/src/main/resources/old/css/jquery.dataTables.css
rename to asterix-examples/src/main/resources/cherry/css/jquery.dataTables.css
diff --git a/asterix-examples/src/main/resources/old/examples/cherry.html b/asterix-examples/src/main/resources/cherry/examples/cherry.html
similarity index 100%
rename from asterix-examples/src/main/resources/old/examples/cherry.html
rename to asterix-examples/src/main/resources/cherry/examples/cherry.html
diff --git a/asterix-examples/src/main/resources/old/img/asterixlogo.png b/asterix-examples/src/main/resources/cherry/img/asterixlogo.png
similarity index 100%
rename from asterix-examples/src/main/resources/old/img/asterixlogo.png
rename to asterix-examples/src/main/resources/cherry/img/asterixlogo.png
Binary files differ
diff --git a/asterix-examples/src/main/resources/old/img/glyphicons-halflings-white.png b/asterix-examples/src/main/resources/cherry/img/glyphicons-halflings-white.png
similarity index 100%
rename from asterix-examples/src/main/resources/old/img/glyphicons-halflings-white.png
rename to asterix-examples/src/main/resources/cherry/img/glyphicons-halflings-white.png
Binary files differ
diff --git a/asterix-examples/src/main/resources/old/img/glyphicons-halflings.png b/asterix-examples/src/main/resources/cherry/img/glyphicons-halflings.png
similarity index 100%
rename from asterix-examples/src/main/resources/old/img/glyphicons-halflings.png
rename to asterix-examples/src/main/resources/cherry/img/glyphicons-halflings.png
Binary files differ
diff --git a/asterix-examples/src/main/resources/old/img/markers.png b/asterix-examples/src/main/resources/cherry/img/markers.png
similarity index 100%
rename from asterix-examples/src/main/resources/old/img/markers.png
rename to asterix-examples/src/main/resources/cherry/img/markers.png
Binary files differ
diff --git a/asterix-examples/src/main/resources/old/img/mobile.png b/asterix-examples/src/main/resources/cherry/img/mobile.png
similarity index 100%
rename from asterix-examples/src/main/resources/old/img/mobile.png
rename to asterix-examples/src/main/resources/cherry/img/mobile.png
Binary files differ
diff --git a/asterix-examples/src/main/resources/old/img/mobile2.png b/asterix-examples/src/main/resources/cherry/img/mobile2.png
similarity index 100%
rename from asterix-examples/src/main/resources/old/img/mobile2.png
rename to asterix-examples/src/main/resources/cherry/img/mobile2.png
Binary files differ
diff --git a/asterix-examples/src/main/resources/old/img/mobile_green.png b/asterix-examples/src/main/resources/cherry/img/mobile_green.png
similarity index 100%
rename from asterix-examples/src/main/resources/old/img/mobile_green.png
rename to asterix-examples/src/main/resources/cherry/img/mobile_green.png
Binary files differ
diff --git a/asterix-examples/src/main/resources/old/img/mobile_green2.png b/asterix-examples/src/main/resources/cherry/img/mobile_green2.png
similarity index 100%
rename from asterix-examples/src/main/resources/old/img/mobile_green2.png
rename to asterix-examples/src/main/resources/cherry/img/mobile_green2.png
Binary files differ
diff --git a/asterix-examples/src/main/resources/old/js/asterix-api-core.js b/asterix-examples/src/main/resources/cherry/js/asterix-api-core.js
similarity index 96%
rename from asterix-examples/src/main/resources/old/js/asterix-api-core.js
rename to asterix-examples/src/main/resources/cherry/js/asterix-api-core.js
index 00a6fbb..13c32b3 100755
--- a/asterix-examples/src/main/resources/old/js/asterix-api-core.js
+++ b/asterix-examples/src/main/resources/cherry/js/asterix-api-core.js
@@ -150,7 +150,7 @@
AsterixCoreAPI.prototype.aql_for = function(for_object) {
var for_statement = "for $";
for (var key in for_object) {
- for_statement += key + " in dataset('" + for_object[key] + "')";
+ for_statement += key + " in dataset " + for_object[key];
}
this.parameters["statements"].push(for_statement);
@@ -243,7 +243,7 @@
"query" : use_dataverse + api.parameters["statements"].join("\n"),
"mode" : api.parameters["mode"]
};
-
+
api.api_helper_proxy_handler(json, callbacks, api.extra);
}
@@ -330,7 +330,7 @@
data: json,
dataType: "json",
success: function(data) {
-
+
// Update API special case
if (data == "") {
api.ui_callback_on_success(api.extra);
@@ -451,6 +451,16 @@
*
* TODO this is kind of hacky :/
*/
+AsterixCoreAPI.prototype.rectangle = function(bounds) {
+ var lower_left = 'create-point(' + bounds["sw"]["lat"] + ',' + bounds["sw"]["lng"] + ')';
+ var upper_right = 'create-point(' + bounds["ne"]["lat"] + ',' + bounds["ne"]["lng"] + ')';
+
+ var rectangle_statement = 'create-rectangle(' + lower_left + ', ' + upper_right + ')';
+ this.parameters["statements"].push(rectangle_statement);
+
+ return this;
+}
+
AsterixCoreAPI.prototype.api_helper_polygon_to_statement = function(bounds) {
var polygon = [];
polygon.push([bounds["ne"]["lat"] + "," + bounds["sw"]["lng"]]);
diff --git a/asterix-examples/src/main/resources/old/js/bootstrap-dropdown.js b/asterix-examples/src/main/resources/cherry/js/bootstrap-dropdown.js
similarity index 100%
rename from asterix-examples/src/main/resources/old/js/bootstrap-dropdown.js
rename to asterix-examples/src/main/resources/cherry/js/bootstrap-dropdown.js
diff --git a/asterix-examples/src/main/resources/old/js/bootstrap.js b/asterix-examples/src/main/resources/cherry/js/bootstrap.js
similarity index 100%
rename from asterix-examples/src/main/resources/old/js/bootstrap.js
rename to asterix-examples/src/main/resources/cherry/js/bootstrap.js
diff --git a/asterix-examples/src/main/resources/old/js/bootstrap.min.js b/asterix-examples/src/main/resources/cherry/js/bootstrap.min.js
similarity index 100%
rename from asterix-examples/src/main/resources/old/js/bootstrap.min.js
rename to asterix-examples/src/main/resources/cherry/js/bootstrap.min.js
diff --git a/asterix-examples/src/main/resources/old/js/cherry.js b/asterix-examples/src/main/resources/cherry/js/cherry.js
similarity index 93%
rename from asterix-examples/src/main/resources/old/js/cherry.js
rename to asterix-examples/src/main/resources/cherry/js/cherry.js
index defc807..97625c5 100755
--- a/asterix-examples/src/main/resources/old/js/cherry.js
+++ b/asterix-examples/src/main/resources/cherry/js/cherry.js
@@ -92,9 +92,9 @@
// setup map
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,
+ mapTypeId: google.maps.MapTypeId.ROADMAP, // SATELLITE
streetViewControl: false,
draggable : false
};
@@ -136,7 +136,7 @@
}
});
- triggerUIUpdateOnNewTweetBook({"title" : "Party"});
+ //triggerUIUpdateOnNewTweetBook({"title" : "Party"});
google.maps.event.addListener(map, 'mousemove', drawRect);
function drawRect (event) {
@@ -231,22 +231,23 @@
// then be passed into another API call or stored
// for a different application purpose.
var buildCherryQuery = new AsterixCoreAPI()
- .aql_for({ "t" : "TwitterData"})
+ .aql_for({ "t" : "TweetMessages"})
.aql_let({
"keyword" : '"' + formData["keyword"] + '"',
"region" : new AsterixCoreAPI()
- .api_helper_polygon_to_statement({
+ .rectangle({
"ne" : { "lat" : formData["neLat"], "lng" : formData["neLng"]},
- "sw" : { "lat" : formData["swLat"], "lng" : formData["swLng"]} })
+ "sw" : { "lat" : formData["swLat"], "lng" : formData["swLng"]}
+ }).parameters["statements"]
})
.aql_where([
- 'spatial-intersect($t.loc, $region)',
- '$t.time > datetime("' + formData["startdt"] + '")',
- '$t.time < datetime("' + formData["enddt"] + '")',
- 'contains($t.text, $keyword)'
+ 'spatial-intersect($t.sender-location, $region)',
+ '$t.send-time > datetime("' + formData["startdt"] + '")',
+ '$t.send-time < datetime("' + formData["enddt"] + '")',
+ 'contains($t.message-text, $keyword)'
])
.aql_groupby({
- "groupby" : "$c := spatial-cell($t.loc, create-point(24.5,-125.5), " + formData["gridlat"].toFixed(1) + ", " + formData["gridlng"].toFixed(1) + ")",
+ "groupby" : "$c := spatial-cell($t.sender-location, create-point(24.5,-125.5), " + formData["gridlat"].toFixed(1) + ", " + formData["gridlng"].toFixed(1) + ")",
"with" : "$t"
})
.aql_return({ "cell" : "$c", "count" : "count($t)" });
@@ -393,38 +394,43 @@
/** Core Query Management and Drilldown
/**
+* Utility Method for parsing a record of this form:
+* { "cell": rectangle("22.5,64.5 24.5,66.5"), "count": 5 }
+* returns a json object with keys: weight, latSW, lngSW, latNE, lngNE
+*/
+function getRecord(cell_count_record) {
+ var record_representation = {};
+
+ var rectangle = cell_count_record.split('")')[0].split('("')[1];
+ record_representation["latSW"] = parseFloat(rectangle.split(" ")[0].split(',')[0]);
+ record_representation["lngSW"] = parseFloat(rectangle.split(" ")[0].split(',')[1]);
+ record_representation["latNE"] = parseFloat(rectangle.split(" ")[1].split(',')[0]);
+ record_representation["lngNE"] = parseFloat(rectangle.split(" ")[1].split(',')[1]);
+ record_representation["weight"] = parseInt(cell_count_record.split('count": ')[1].split(" ")[0]);
+
+ return record_representation;
+}
+
+/**
* A spatial data cleaning and mapping call
* @param {Object} res, a result object from a cherry geospatial query
* @param {Object} extra, extra data passed from the API call - legacy stuff
*/
function cherryQuerySyncCallback(res, extra) {
-
- var response = $.parseJSON(res[0])
+ var response = $.parseJSON(res[0]);
records = response["results"];
-
+
var coordinates = [];
- var coordinate = [];
var weights = [];
- for (var subr = 0; subr < records.length; subr++) {
- for (var record in records[subr]) {
-
- var cell = records[subr][record].split(")")[0].split("(")[1];
- var count = records[subr][record].split("count")[1].split(":")[1].split(' ')[1];
- coordinate = {
- "weight" : parseInt(count),
-
- // x is actually up-down, y is left-right
- "latSW" : parseFloat(cell.split("|")[0].split(",")[0].split('"')[1]),
- "lngSW" : -1*parseFloat(cell.split("|")[0].split(",")[1]),
- "latNE" : parseFloat(cell.split("|")[1].split(",")[0]),
- "lngNE" : -1*parseFloat(cell.split("|")[1].split(",")[1].split('"')[0]),
- };
- weights.push(parseInt(count));
+ for (var subrecord in records) {
+ for (var record in records[subrecord]) {
+
+ var coordinate = getRecord(records[subrecord][record]);
+ weights.push(coordinate["weight"]);
coordinates.push(coordinate);
}
}
-
triggerUIUpdate(coordinates, extra["payload"], weights);
}
@@ -451,7 +457,7 @@
var mapColor = mapWidgetLegendGetHeatValue(mapPlotData[m].weight, dataBreakpoints);
var markerRadius = mapWidgetComputeCircleRadius(mapPlotData[m], dataBreakpoints);
var point_opacity = 1.0; // TODO
-
+
var point_center = new google.maps.LatLng(
(mapPlotData[m].latSW + mapPlotData[m].latNE)/2.0,
(mapPlotData[m].lngSW + mapPlotData[m].lngNE)/2.0);
@@ -509,17 +515,17 @@
map.fitBounds(customBounds);
var drilldown_string = ["use dataverse " + "twitter" + ";",
- "for $t in dataset('" + "TwitterData" + "')",
+ "for $t in dataset('" + "TweetMessages" + "')",
"let $keyword := \"" +zoneData["keyword"] + "\"",
"let $region := polygon(\"",
zoneData["neLat"] + "," + zoneData["swLng"] + " ",
zoneData["swLat"] + "," + zoneData["swLng"] + " ",
zoneData["swLat"] + "," + zoneData["neLng"] + " ",
zoneData["neLat"] + "," + zoneData["neLng"] + "\")",
- "where spatial-intersect($t.loc, $region) and",
- "$t.time > datetime(\"" + zoneData["startdt"] + "\") and $t.time < datetime(\"" + zoneData["enddt"] + "\") and",
- "contains($t.text, $keyword)",
- "return { \"tweetId\": $t.tweetid, \"tweetText\": $t.text, \"tweetLoc\": $t.loc}"];
+ "where spatial-intersect($t.sender-location, $region) and",
+ "$t.send-time > datetime(\"" + zoneData["startdt"] + "\") and $t.send-time < datetime(\"" + zoneData["enddt"] + "\") and",
+ "contains($t.message-text, $keyword)",
+ "return { \"tweetId\": $t.tweetid, \"tweetText\": $t.message-text, \"tweetLoc\": $t.sender-location}"];
var zQ = new AsterixCoreAPI()
.dataverse("twitter")
diff --git a/asterix-examples/src/main/resources/old/js/geostats.js b/asterix-examples/src/main/resources/cherry/js/geostats.js
similarity index 100%
rename from asterix-examples/src/main/resources/old/js/geostats.js
rename to asterix-examples/src/main/resources/cherry/js/geostats.js
diff --git a/asterix-examples/src/main/resources/old/js/jquery.dataTables.min.js b/asterix-examples/src/main/resources/cherry/js/jquery.dataTables.min.js
similarity index 100%
rename from asterix-examples/src/main/resources/old/js/jquery.dataTables.min.js
rename to asterix-examples/src/main/resources/cherry/js/jquery.dataTables.min.js