Cherry Demo Fixes
diff --git a/asterix-examples/src/main/resources/cherry/js/asterix-api-core.js b/asterix-examples/src/main/resources/cherry/js/asterix-api-core.js
index e5d64eb..9553997 100755
--- a/asterix-examples/src/main/resources/cherry/js/asterix-api-core.js
+++ b/asterix-examples/src/main/resources/cherry/js/asterix-api-core.js
@@ -460,32 +460,3 @@
AsterixCoreAPI.prototype.api_helper_default_on_error = function (error_code, error_message) {
alert("ERROR " + error_code + ": " + error_message);
}
-
-/**
-* API Helper - Spatial/Polygon Creator
-*
-* @param {Object} bounds, {"ne" => { "lat", "lng" }, "sw" => {"lat", "lng"} }
-* @returns {String} query string form of a polygon
-*
-* 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"]]);
- polygon.push([bounds["sw"]["lat"] + "," + bounds["sw"]["lng"]]);
- polygon.push([bounds["sw"]["lat"] + "," + bounds["ne"]["lng"]]);
- polygon.push([bounds["ne"]["lat"] + "," + bounds["ne"]["lng"]]);
-
- var polygon_statement = 'polygon("' + polygon.join(" ") + '")';
- return polygon_statement;
-}
diff --git a/asterix-examples/src/main/resources/cherry/js/cherry.js b/asterix-examples/src/main/resources/cherry/js/cherry.js
index 3eccda9..2044668 100755
--- a/asterix-examples/src/main/resources/cherry/js/cherry.js
+++ b/asterix-examples/src/main/resources/cherry/js/cherry.js
@@ -222,7 +222,11 @@
formData["swLng"] = Math.abs(bounds.getSouthWest().lng());
formData["neLat"] = Math.abs(bounds.getNorthEast().lat());
formData["neLng"] = Math.abs(bounds.getNorthEast().lng());
-
+ var formBounds = {
+ "ne" : { "lat" : formData["neLat"], "lng" : formData["neLng"]},
+ "sw" : { "lat" : formData["swLat"], "lng" : formData["swLng"]}
+ };
+
var build_cherry_mode = "synchronous";
if ($('#asbox').is(":checked")) {
build_cherry_mode = "asynchronous";
@@ -232,23 +236,18 @@
// It can also be used to generate queries, which can
// then be passed into another API call or stored
// for a different application purpose.
- .rectangle({
- "ne" : { "lat" : formData["neLat"], "lng" : formData["neLng"]},
- "sw" : { "lat" : formData["swLat"], "lng" : formData["swLng"]}
- })
-
var l = new LegacyExpression()
.dataverse("twitter")
.bind(new ForClause("t", new AsterixClause().set("TweetMessages")))
.bind(new LetClause("keyword", new AsterixClause().set('"' + formData["keyword"] + '"')))
- .bind(new LetClause("region", new ????))// TODO
- .bind(new WhereClause("where " + [ // TODO
+ .bind(new LetClause("region", new AsterixSDK().rectangle(formBounds)))
+ .bind(new WhereClause("where " + [
'spatial-intersect($t.sender-location, $region)',
'$t.send-time > datetime("' + formData["startdt"] + '")',
'$t.send-time < datetime("' + formData["enddt"] + '")',
'contains($t.message-text, $keyword)'
]).join(" "))
- .bind(new GroupClause().set("group by $c := spatial-cell($t.sender-location, create-point(24.5,-125.5), " + formData["gridlat"].toFixed(1) + ", " + formData["gridlng"].toFixed(1) + ")")) // TODO
+ .bind(new GroupClause().set("group by $c := spatial-cell($t.sender-location, create-point(24.5,-125.5), " + formData["gridlat"].toFixed(1) + ", " + formData["gridlng"].toFixed(1) + ")"))
.return({ "cell" : "$c", "count" : "count($t)" })
.success(cherryQuerySyncCallback, true)
.success(cherryQueryAsyncCallback, false)