Skip to content

Commit 6dee30c

Browse files
authored
bug fixes (#156)
1 parent d72a077 commit 6dee30c

File tree

7 files changed

+59
-17
lines changed

7 files changed

+59
-17
lines changed

back-end/src/main/java/index/Indexer.java

+27
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.io.Serializable;
88
import java.lang.reflect.Method;
99
import java.sql.SQLException;
10+
import java.sql.Statement;
1011
import java.util.ArrayList;
1112
import java.util.HashMap;
1213
import java.util.Map;
@@ -15,10 +16,12 @@
1516
import jdk.nashorn.api.scripting.JSObject;
1617
import jdk.nashorn.api.scripting.NashornScriptEngine;
1718
import main.Config;
19+
import main.DbConnector;
1820
import main.Main;
1921
import project.Canvas;
2022
import project.Layer;
2123
import project.Placement;
24+
import project.SSV;
2225

2326
/** Created by wenbo on 12/30/18. */
2427
public abstract class Indexer implements Serializable {
@@ -91,6 +94,30 @@ else if (Config.indexingScheme == Config.indexingScheme.TILE_INDEX)
9194
l.setIndexer(indexer);
9295
l.setIndexerType(indexer.getClass().getSimpleName());
9396

97+
// for geo ssv layers, add kyrix_geo_x/kyrix_geo_y columns first
98+
// so that getTransform().getColumnNames() below can find them
99+
if (!l.getSSVId().isEmpty()) {
100+
int ssvIndex =
101+
Integer.valueOf(l.getSSVId().substring(0, l.getSSVId().indexOf("_")));
102+
SSV curSSV = Main.getProject().getSsvs().get(ssvIndex);
103+
// check if geo component is specified
104+
if (curSSV.getGeoInitialLevel() >= 0) {
105+
String rawTable = curSSV.getRawTable();
106+
String db = curSSV.getDb();
107+
Statement rawDbStmt = DbConnector.getStmtByDbName(db);
108+
String sql =
109+
"ALTER TABLE "
110+
+ rawTable
111+
+ " ADD COLUMN IF NOT EXISTS kyrix_geo_x float;";
112+
rawDbStmt.executeUpdate(sql);
113+
sql =
114+
"ALTER TABLE "
115+
+ rawTable
116+
+ " ADD COLUMN IF NOT EXISTS kyrix_geo_y float;";
117+
rawDbStmt.executeUpdate(sql);
118+
}
119+
}
120+
94121
// pre-run getColumnNames, see issue #84: github.com/tracyhenry/kyrix/issues/84
95122
l.getTransform().getColumnNames();
96123
}

back-end/src/main/java/index/SSVInMemoryIndexer.java

+11-7
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,6 @@ public void createMV(Canvas c, int layerId) throws Exception {
161161
// set common variables
162162
setCommonVariables();
163163

164-
// transform geo to screen coordinates if needed
165-
if (!ssv.getGeoLatCol().isEmpty()) getGeoCoords();
166-
167164
// compute cluster aggregations
168165
long st = System.nanoTime();
169166
computeClusterAggs();
@@ -198,6 +195,9 @@ private void setCommonVariables() throws Exception {
198195
overlappingThreshold = Math.max(overlappingThreshold, ssv.getOverlap());
199196
System.out.println("Overlapping threshold: " + overlappingThreshold);
200197

198+
// transform geo to screen coordinates if needed
199+
if (!ssv.getGeoLatCol().isEmpty()) getGeoCoords();
200+
201201
// store raw query results into memory
202202
rawRows = DbConnector.getQueryResult(ssv.getDb(), ssv.getQuery());
203203
for (int i = 0; i < rawRows.size(); i++)
@@ -220,7 +220,7 @@ private void getGeoCoords() throws Exception {
220220
System.out.println(sql);
221221
rawDbStmt.executeUpdate(sql);
222222

223-
sql = "DROP FUNCTION get_coord";
223+
sql = "DROP FUNCTION IF EXISTS get_coord;";
224224
System.out.println(sql);
225225
rawDbStmt.executeUpdate(sql);
226226

@@ -249,7 +249,11 @@ private void getGeoCoords() throws Exception {
249249
sql =
250250
"UPDATE "
251251
+ ssv.getRawTable()
252-
+ " SET kyrix_geo_x = ((get_coord(latitude::float, longitude::float)->>'x')::float),"
252+
+ " SET kyrix_geo_x = ((get_coord("
253+
+ ssv.getGeoLatCol()
254+
+ "::float, "
255+
+ ssv.getGeoLonCol()
256+
+ "::float)->>'x')::float),"
253257
+ " kyrix_geo_y = ((get_coord(latitude::float, longitude::float)->>'y')::float);";
254258
System.out.println(sql);
255259
rawDbStmt.executeUpdate(sql);
@@ -479,8 +483,8 @@ private void calculateBGRP(RTreeData[] rds, int level)
479483

480484
private void cleanUp() throws SQLException {
481485
// commit & close connections
482-
rawDbStmt.close();
483-
bboxStmt.close();
486+
if (rawDbStmt != null) rawDbStmt.close();
487+
if (bboxStmt != null) bboxStmt.close();
484488
DbConnector.closeConnection(ssv.getDb());
485489
DbConnector.closeConnection(Config.databaseName);
486490

back-end/src/main/java/server/IndexHandler.java

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ else if (path.contains(".jpg"))
5151
e.printStackTrace();
5252
System.out.println("\n\n" + e.getMessage() + "\n");
5353
Server.printServingErrorMessage();
54+
Server.sendResponse(httpExchange, HttpsURLConnection.HTTP_NO_CONTENT, "");
5455
}
5556
}
5657
}

compiler/src/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,8 @@ function saveProject() {
593593
throw new Error(
594594
"Auto drill down for MySQL is not supported right now."
595595
);
596+
if (this.views.length == 0)
597+
throw new Error("No view object specified in the project.");
596598
for (var i = 0; i < this.canvases.length; i++) {
597599
// a canvas should have at least one layer
598600
if (this.canvases[i].layers.length == 0)

compiler/src/template-api/SSV.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -1662,7 +1662,9 @@ function getMapRenderer() {
16621662
var vy = args["viewportY"];
16631663
var vw = args["viewportW"];
16641664
var vh = args["viewportH"];
1665-
var level = args["pyramidLevel"];
1665+
var topLevelWidth = params.hiX - params.loX;
1666+
var topLevelHeight = params.hiY - params.loY;
1667+
var level = +args.ssvId.substring(args.ssvId.indexOf("_") + 1);
16661668
var initialLon = params.geoInitialCenterLon;
16671669
var initialLat = params.geoInitialCenterLat;
16681670
var initialLevel = params.geoInitialLevel;
@@ -1672,16 +1674,16 @@ function getMapRenderer() {
16721674

16731675
// note: vw/3 because dynamic boxes fetch a box slightly larger than viewport
16741676
var minTileX = Math.floor(
1675-
(cx - (vw * (1 << level)) / 2 + vx - vw / 3) / 256
1677+
(cx - (topLevelWidth * (1 << level)) / 2 + vx - vw / 3) / 256
16761678
);
16771679
var maxTileX = Math.floor(
1678-
(cx - (vw * (1 << level)) / 2 + vx + vw + vw / 3) / 256
1680+
(cx - (topLevelWidth * (1 << level)) / 2 + vx + vw + vw / 3) / 256
16791681
);
16801682
var minTileY = Math.floor(
1681-
(cy - (vh * (1 << level)) / 2 + vy - vh / 3) / 256
1683+
(cy - (topLevelHeight * (1 << level)) / 2 + vy - vh / 3) / 256
16821684
);
16831685
var maxTileY = Math.floor(
1684-
(cy - (vh * (1 << level)) / 2 + vy + vh + vh / 3) / 256
1686+
(cy - (topLevelHeight * (1 << level)) / 2 + vy + vh + vh / 3) / 256
16851687
);
16861688
var tiles = [];
16871689
for (var i = minTileX; i <= maxTileX; i++)
@@ -1712,10 +1714,10 @@ function getMapRenderer() {
17121714
);
17131715
})
17141716
.attr("x", function(d) {
1715-
return d[0] * 256 - (cx - (vw * (1 << level)) / 2);
1717+
return d[0] * 256 - (cx - (topLevelWidth * (1 << level)) / 2);
17161718
})
17171719
.attr("y", function(d) {
1718-
return d[1] * 256 - (cy - (vh * (1 << level)) / 2);
1720+
return d[1] * 256 - (cy - (topLevelHeight * (1 << level)) / 2);
17191721
})
17201722
.attr("width", 256)
17211723
.attr("height", 256);

front-end/js/jump.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
function removePopovers(viewId) {
2-
var selector = ".popover,.kyrixtooltip";
2+
var selector = ".popover";
33
if (viewId != null) selector += ".view_" + viewId;
4+
selector += ",.kyrixtooltip";
45
d3.selectAll(selector).remove();
56
}
67

78
function removePopoversSmooth(viewId) {
8-
var selector = ".popover,.kyrixtooltip";
9+
var selector = ".popover";
910
if (viewId != null) selector += ".view_" + viewId;
11+
selector += ",.kyrixtooltip";
1012
d3.selectAll(selector)
1113
.transition()
1214
.duration(param.popoverOutDuration)

front-end/js/jumpAnimation.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ function animateSemanticZoom(viewId, jump, newVpX, newVpY, tuple) {
4242

4343
// get client dx & dy
4444
var thisBox = this.getBoundingClientRect();
45-
var ancestorBox = ancestor.getBoundingClientRect();
45+
var ancestorBox = d3
46+
.select(ancestor)
47+
.select("rect")
48+
.node()
49+
.getBoundingClientRect();
4650
var dx = thisBox.x - ancestorBox.x;
4751
var dy = thisBox.y - ancestorBox.y;
4852

0 commit comments

Comments
 (0)