Skip to content

Commit d0e82ad

Browse files
committed
Add support for thematic KML datasource
1 parent 367dcea commit d0e82ad

File tree

6 files changed

+176
-1
lines changed

6 files changed

+176
-1
lines changed

3dwebclient/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@
7272
<script src="utils/mashup-data-source-service/core/WritableDataSource.js"></script>
7373
<script src="utils/mashup-data-source-service/core/DataSource.js"></script>
7474
<script src="utils/mashup-data-source-service/core/SQLDataSource.js"></script>
75+
<script src="utils/mashup-data-source-service/core/XMLDataSource.js"></script>
7576
<script src="utils/mashup-data-source-service/application/GoogleSheets.js"></script>
7677
<script src="utils/mashup-data-source-service/application/PostgreSQL.js"></script>
78+
<script src="utils/mashup-data-source-service/application/KMLDataSource.js"></script>
7779
<script src="utils/mashup-data-source-service/core/MashupDataSource.js"></script>
7880
<script src="utils/mashup-data-source-service/application/DataSourceController.js"></script>
7981

@@ -291,6 +293,7 @@
291293
<select id="thematicDataSourceDropdown" data-bind="value: thematicDataSource" onchange="thematicDataSourceAndTableTypeDropdownOnchange()">
292294
<option value="GoogleSheets" selected="selected">Google Sheets API</option>
293295
<option value="PostgreSQL">PostgreSQL REST API</option>
296+
<option value="KML">KML Documents</option>
294297
</select>
295298
</td>
296299
</tr>

3dwebclient/script.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,10 @@ function addEventListeners(layer) {
646646
}
647647

648648
layer.registerEventHandler("CLICK", function (object) {
649+
var thematicDataSourceDropdown = document.getElementById("thematicDataSourceDropdown");
650+
var selectedThematicDataSource = thematicDataSourceDropdown.options[thematicDataSourceDropdown.selectedIndex].value;
649651
var res = auxClickEventListener(object);
650-
createInfoTable(res[0], res[1], layer);
652+
createInfoTable(selectedThematicDataSource === "KML" ? res[1]._id : res[0], res[1], layer);
651653
});
652654

653655
layer.registerEventHandler("CTRLCLICK", function (object) {
@@ -1367,6 +1369,10 @@ function thematicDataSourceAndTableTypeDropdownOnchange() {
13671369
// provider: "",
13681370
uri: addLayerViewModel.thematicDataUrl,
13691371
tableType: selectedTableType,
1372+
thirdPartyHandler: {
1373+
type: "Cesium",
1374+
handler: webMap._activeLayer ? webMap._activeLayer._citydbKmlDataSource : undefined
1375+
},
13701376
// ranges: addLayerViewModel.googleSheetsRanges,
13711377
// apiKey: addLayerViewModel.googleSheetsApiKey,
13721378
// clientId: addLayerViewModel.googleSheetsClientId

3dwebclient/utils/mashup-data-source-service/application/DataSourceController.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@ var DataSourceTypes;
22
(function (DataSourceTypes) {
33
DataSourceTypes["GoogleSheets"] = "GoogleSheets";
44
DataSourceTypes["PostgreSQL"] = "PostgreSQL";
5+
DataSourceTypes["KML"] = "KML";
56
})(DataSourceTypes || (DataSourceTypes = {}));
67
var TableTypes;
78
(function (TableTypes) {
89
TableTypes["Horizontal"] = "Horizontal";
910
TableTypes["Vertical"] = "Vertical";
1011
})(TableTypes || (TableTypes = {}));
12+
var ThirdPartyHandler;
13+
(function (ThirdPartyHandler) {
14+
ThirdPartyHandler["Cesium"] = "Cesium";
15+
})(ThirdPartyHandler || (ThirdPartyHandler = {}));
1116
var DataSourceController = /** @class */ (function () {
1217
function DataSourceController(selectedDataSource, signInController, options) {
1318
var scope = this;
@@ -18,6 +23,9 @@ var DataSourceController = /** @class */ (function () {
1823
else if (selectedDataSource == DataSourceTypes.PostgreSQL) {
1924
scope._dataSource = new PostgreSQL(signInController, scope._options);
2025
}
26+
else if (selectedDataSource == DataSourceTypes.KML) {
27+
scope._dataSource = new KMLDataSource(signInController, scope._options);
28+
}
2129
}
2230
DataSourceController.prototype.fetchData = function (id, callback, limit) {
2331
var scope = this;
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
var __extends = (this && this.__extends) || (function () {
2+
var extendStatics = function (d, b) {
3+
extendStatics = Object.setPrototypeOf ||
4+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6+
return extendStatics(d, b);
7+
};
8+
return function (d, b) {
9+
extendStatics(d, b);
10+
function __() { this.constructor = d; }
11+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12+
};
13+
})();
14+
var KMLDataSource = /** @class */ (function (_super) {
15+
__extends(KMLDataSource, _super);
16+
function KMLDataSource(signInController, options) {
17+
return _super.call(this, signInController, options) || this;
18+
}
19+
KMLDataSource.prototype.responseToKvp = function (response) {
20+
if (this._thirdPartyHandler) {
21+
switch (this._thirdPartyHandler.type) {
22+
case ThirdPartyHandler.Cesium: {
23+
// the handler is Cesium.KMLDataSource
24+
return this.responseCesiumToKvp(response);
25+
break;
26+
}
27+
default: {
28+
// no valid handler found
29+
return this.responseOwnToKvp(response);
30+
break;
31+
}
32+
}
33+
}
34+
};
35+
KMLDataSource.prototype.responseCesiumToKvp = function (response) {
36+
// response is already in JSON
37+
// only support Data https://cesium.com/docs/cesiumjs-ref-doc/KmlFeatureData.html
38+
var result = new Map();
39+
/* <Data name="">
40+
<displayName></displayName>
41+
<value></value>
42+
</Data
43+
*/
44+
for (var key in response) {
45+
// if no displayName is available -> use attribute name instead
46+
if (response[key] && response[key].displayName) {
47+
result[response[key].displayName] = response[key].value;
48+
}
49+
else {
50+
result[key] = response[key].value;
51+
}
52+
}
53+
return result;
54+
};
55+
KMLDataSource.prototype.responseOwnToKvp = function (response) {
56+
// TODO
57+
return null;
58+
};
59+
KMLDataSource.prototype.countFromResult = function (res) {
60+
return res.getSize();
61+
};
62+
KMLDataSource.prototype.deleteDataRecordUsingId = function (id) {
63+
// TODO
64+
return null;
65+
};
66+
KMLDataSource.prototype.fetchIdsFromResult = function (res) {
67+
// TODO
68+
return null;
69+
};
70+
KMLDataSource.prototype.insertDataRecord = function (record) {
71+
// TODO
72+
return null;
73+
};
74+
KMLDataSource.prototype.queryUsingIds = function (ids) {
75+
// TODO
76+
return null;
77+
};
78+
KMLDataSource.prototype.queryUsingNames = function (names, limit) {
79+
// TODO
80+
return null;
81+
};
82+
KMLDataSource.prototype.queryUsingId = function (id, callback, limit) {
83+
if (this._thirdPartyHandler) {
84+
// prioritize the implementation of the provided 3rd-party handler
85+
switch (this._thirdPartyHandler.type) {
86+
case ThirdPartyHandler.Cesium: {
87+
// the handler is Cesium.KMLDataSource
88+
var entities = this._thirdPartyHandler.handler.entities;
89+
var entity = entities.getById(id);
90+
// entity is Cesium.KMLFeatureData
91+
callback(entity.kml.extendedData);
92+
break;
93+
}
94+
default: {
95+
// no valid handler found
96+
callback(null);
97+
break;
98+
}
99+
}
100+
}
101+
else {
102+
// using own implementation
103+
// TODO
104+
}
105+
};
106+
KMLDataSource.prototype.queryUsingSql = function (sql, callback, limit) {
107+
// TODO
108+
return;
109+
};
110+
KMLDataSource.prototype.queryUsingTypes = function (types, limit) {
111+
// TODO
112+
return null;
113+
};
114+
KMLDataSource.prototype.sumFromResultByColIndex = function (res, colIndex) {
115+
// TODO
116+
return null;
117+
};
118+
KMLDataSource.prototype.sumFromResultByName = function (res, name) {
119+
// TODO
120+
return null;
121+
};
122+
KMLDataSource.prototype.updateDataRecordUsingId = function (id, newRecord) {
123+
// TODO
124+
return null;
125+
};
126+
return KMLDataSource;
127+
}(XMLDataSource));

3dwebclient/utils/mashup-data-source-service/core/DataSource.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ var DataSource = /** @class */ (function () {
1111
this._uri = !options.uri ? "" : options.uri;
1212
this._capabilities = !options.capabilities ? undefined : options.capabilities;
1313
this._tableType = !options.tableType ? TableTypes.Horizontal : options.tableType;
14+
this._thirdPartyHandler = !options.thirdPartyHandler ? undefined : options.thirdPartyHandler;
1415
this._signInController = signInController;
1516
}
1617
Object.defineProperty(DataSource.prototype, "name", {
@@ -83,6 +84,16 @@ var DataSource = /** @class */ (function () {
8384
enumerable: true,
8485
configurable: true
8586
});
87+
Object.defineProperty(DataSource.prototype, "thirdPartyHandler", {
88+
get: function () {
89+
return this._thirdPartyHandler;
90+
},
91+
set: function (value) {
92+
this._thirdPartyHandler = value;
93+
},
94+
enumerable: true,
95+
configurable: true
96+
});
8697
Object.defineProperty(DataSource.prototype, "signInController", {
8798
get: function () {
8899
return this._signInController;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var __extends = (this && this.__extends) || (function () {
2+
var extendStatics = function (d, b) {
3+
extendStatics = Object.setPrototypeOf ||
4+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6+
return extendStatics(d, b);
7+
};
8+
return function (d, b) {
9+
extendStatics(d, b);
10+
function __() { this.constructor = d; }
11+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12+
};
13+
})();
14+
var XMLDataSource = /** @class */ (function (_super) {
15+
__extends(XMLDataSource, _super);
16+
function XMLDataSource(signInController, options) {
17+
return _super.call(this, signInController, options) || this;
18+
}
19+
return XMLDataSource;
20+
}(DataSource));

0 commit comments

Comments
 (0)