Skip to content

Commit 20fce6b

Browse files
author
Anyplace
authored
Merge pull request #233 from dmsl/develop
v3.3 Merge
2 parents 979eff9 + bf607e6 commit 20fce6b

File tree

18 files changed

+203
-69
lines changed

18 files changed

+203
-69
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# AnyPlace v3.2 (March 2018)
1+
# AnyPlace v3.3 (April 2018)
22

33
[![Join the chat at https://gitter.im/dmsl/anyplace](https://badges.gitter.im/dmsl/anyplace.svg)](https://gitter.im/dmsl/anyplace?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
44

@@ -55,7 +55,7 @@ DEALINGS IN THE SOFTWARE.
5555

5656
Short description of the contents included in this release.
5757

58-
### A. Server v3.2
58+
### A. Server v3.3
5959

6060
The server entails all components to run the anyplace service on your own server.
6161

@@ -64,7 +64,7 @@ The server entails all components to run the anyplace service on your own server
6464
- Instructions: https://github.com/dmsl/anyplace/tree/master/server
6565
- Current Leaders: Constantinos Costa, Kyriakos Georgiou
6666

67-
#### > Viewer v3.2
67+
#### > Viewer v3.3
6868
The source code of Anyplace HTML5/CSS3 Viewer Client (IP localization).
6969
- Try: https://anyplace.cs.ucy.ac.cy/viewer/
7070
- Documentation/Source: https://github.com/dmsl/anyplace/tree/master/server/public/anyplace_viewer

server/app/controllers/AnyplaceMapping.scala

+61-1
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ object AnyplaceMapping extends play.api.mvc.Controller {
425425
var x = accessPoint.getString("x").toDouble
426426
var y = accessPoint.getString("y").toDouble
427427
if (ap == null) {
428-
if (avg < -40) {
428+
if (avg < -60) {
429429
accessPoint.put("den", avg)
430430
accessPoint.put("x", avg * x)
431431
accessPoint.put("y", avg * y)
@@ -634,6 +634,66 @@ object AnyplaceMapping extends play.api.mvc.Controller {
634634
inner(request)
635635
}
636636

637+
def FingerPrintsTimestampDelete() = Action {
638+
implicit request =>
639+
def inner(request: Request[AnyContent]): Result = {
640+
val anyReq = new OAuth2Request(request)
641+
if (!anyReq.assertJsonBody)
642+
return AnyResponseHelper.bad_request(AnyResponseHelper.CANNOT_PARSE_BODY_AS_JSON)
643+
var json = anyReq.getJsonBody
644+
LPLogger.info("AnyplaceMapping::FingerPrintsTimestampDelete(): " + json.toString)
645+
val requiredMissing = JsonUtils.requirePropertiesInJson(json, "buid", "floor", "lat1", "lon1", "lat2", "lon2","timestampX","timestampY")
646+
if (!requiredMissing.isEmpty)
647+
return AnyResponseHelper.requiredFieldsMissing(requiredMissing)
648+
649+
val buid = (json \ "buid").as[String]
650+
val floor_number = (json \ "floor").as[String]
651+
val lat1 = (json \ "lat1").as[String]
652+
val lon1 = (json \ "lon1").as[String]
653+
val lat2 = (json \ "lat2").as[String]
654+
val lon2 = (json \ "lon2").as[String]
655+
val timestampX = (json \ "timestampX").as[String]
656+
val timestampY = (json \ "timestampY").as[String]
657+
658+
659+
try {
660+
val radioPoints: util.List[JsonObject] = ProxyDataSource.getIDatasource.getFingerPrintsTimestampBBox(buid, floor_number, lat1, lon1, lat2, lon2, timestampX, timestampY)
661+
if (radioPoints.isEmpty)
662+
return AnyResponseHelper.bad_request("FingerPrints does not exist or could not be retrieved!")
663+
664+
for (i <- 0 until radioPoints.size())
665+
ProxyDataSource.getIDatasource.deleteFromKey(radioPoints.get(i).getString("id"))
666+
667+
668+
val res = JsonObject.empty()
669+
res.put("radioPoints", radioPoints)
670+
try // if (request().getHeader("Accept-Encoding") != null && request().getHeader("Accept-Encoding").contains("gzip")) {
671+
{
672+
//Regenerate the radiomap files
673+
val strPromise = F.Promise.pure("10")
674+
val intPromise = strPromise.map(new F.Function[String, Integer]() {
675+
override def apply(arg0: String): java.lang.Integer = {
676+
AnyplacePosition.updateFrozenRadioMap(buid, floor_number)
677+
0
678+
}
679+
})
680+
gzippedJSONOk(res.toString)
681+
// }
682+
// return AnyResponseHelper.ok(res.toString());
683+
} catch {
684+
case ioe: IOException =>
685+
return AnyResponseHelper.ok(res, "Successfully retrieved all FingerPrints!")
686+
}
687+
} catch {
688+
case e: DatasourceException =>
689+
return AnyResponseHelper.internal_server_error("Server Internal Error [" + e.getMessage + "]")
690+
}
691+
692+
}
693+
694+
inner(request)
695+
}
696+
637697
//end new marileni
638698

639699
def FingerPrintsTime() = Action {

server/app/datasources/CouchbaseDatasource.scala

+37
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,43 @@ class CouchbaseDatasource private(hostname: String,
819819
points
820820
}
821821

822+
override def getFingerPrintsTimestampBBox(buid: String, floor: String, lat1: String, lon1: String, lat2: String, lon2: String, timestampX: String, timestampY: String): util.List[JsonObject] = {
823+
824+
val points = new util.ArrayList[JsonObject]
825+
826+
val couchbaseClient = getConnection
827+
828+
val bbox = GeoPoint.getGeoBoundingBoxByRange(lat1.toDouble, lon1.toDouble, lat2.toDouble, lon2.toDouble)
829+
830+
val viewQuery = SpatialViewQuery.from("radio_spatial", "radio_buid_floor")
831+
.startRange(JsonArray.from(new java.lang.Double(bbox(0).dlat), new java.lang.Double(bbox(0).dlon)))
832+
.endRange(JsonArray.from(new java.lang.Double(bbox(1).dlat), new java.lang.Double(bbox(1).dlon))).includeDocs(true)
833+
val res = couchbaseClient.query(viewQuery)
834+
835+
836+
//System.out.println("couchbase results: " + res.size)
837+
838+
var json: JsonObject = null
839+
for (row <- res.allRows()) { // handle each building entry
840+
try {
841+
val document = row.document()
842+
json = document.content()
843+
if ((json.getString("buid").compareTo(buid) == 0) && (json.getString("floor").compareTo(floor) == 0)) {
844+
if((json.getString("timestamp").compareTo(timestampX)>=0) && (json.getString("timestamp").compareTo(timestampY)<=0))
845+
points.add(JsonObject.create().put("id", document.id()))
846+
847+
}
848+
} catch {
849+
case e: IOException =>
850+
851+
// skip this NOT-JSON document
852+
}
853+
}
854+
855+
points
856+
}
857+
858+
822859
override def getFingerPrintsTime(buid: String, floor: String): util.List[JsonObject] = {
823860
val points = new ArrayList[JsonObject]()
824861
val couchbaseClient = getConnection

server/app/datasources/IDatasource.scala

+2
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ trait IDatasource {
122122

123123
def getFingerPrintsBBox(buid: String, floor: String,lat1: String, lon1: String, lat2: String, lon2: String): List[JsonObject]
124124

125+
def getFingerPrintsTimestampBBox(buid: String, floor: String, lat1: String, lon1: String, lat2: String, lon2: String, timestampX: String, timestampY: String): List[JsonObject]
126+
125127
def getFingerPrintsTime(buid: String, floor: String): List[JsonObject]
126128

127129
def getRadioHeatmapByBuildingFloor2(lat: String, lon: String, buid: String, floor: String, range: Int): List[JsonObject]

server/app/datasources/ProxyDataSource.scala

+4
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ class ProxyDataSource private() extends IDatasource {
235235
_checkActiveDatasource()
236236
mActiveDatabase.getFingerPrintsBBox(buid,floor,lat1,lon1,lat2,lon2)
237237
}
238+
override def getFingerPrintsTimestampBBox(buid: String, floor: String, lat1: String, lon1: String, lat2: String, lon2: String, timestampX: String, timestampY: String): util.List[JsonObject] = {
239+
_checkActiveDatasource()
240+
mActiveDatabase.getFingerPrintsTimestampBBox(buid: String, floor: String, lat1: String, lon1: String, lat2: String, lon2: String, timestampX: String, timestampY: String)
241+
}
238242

239243
override def getFingerPrintsTime(buid: String, floor: String): util.List[JsonObject] = {
240244
_checkActiveDatasource()

server/conf/routes

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ POST /anyplace/position/radio/heatmap_building_floor_timestamp_average_3
3535
POST /anyplace/position/radio/APs_building_floor controllers.AnyplaceMapping.getAPsByBuildingFloor()
3636
POST /anyplace/position/radio/aps_ids controllers.AnyplaceMapping.getAPsIds()
3737
POST /anyplace/position/radio/delete controllers.AnyplaceMapping.FingerPrintsDelete()
38+
POST /anyplace/position/radio/delete/time controllers.AnyplaceMapping.FingerPrintsTimestampDelete()
3839
POST /anyplace/position/radio/time controllers.AnyplaceMapping.FingerPrintsTime()
3940
POST /anyplace/position/radio/acces controllers.AnyplaceMapping.getAccesHeatmapByBuildingFloor()
4041

server/public/anyplace_architect/app.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ app.service('GMapService', function () {
5353
},
5454
scaleControl: true,
5555
streetViewControl: false,
56-
overviewMapControl: true
56+
overviewMapControl: true,
57+
fullscreenControl: false
5758

5859
};
5960

server/public/anyplace_architect/controllers/WiFiController.js

+20-6
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ app.controller('WiFiController', ['$cookieStore','$scope', 'AnyplaceService', 'G
351351

352352
if( $scope.radioHeatmapRSSTimeMode ){
353353
d3.selectAll("svg > *").remove();
354+
$( "svg" ).remove();
354355
$scope.getFingerPrintsTime();
355356
}
356357

@@ -395,6 +396,7 @@ app.controller('WiFiController', ['$cookieStore','$scope', 'AnyplaceService', 'G
395396

396397
if($scope.fingerPrintsTimeMode && !$scope.radioHeatmapRSSTimeMode){
397398
d3.selectAll("svg > *").remove();
399+
$( "svg" ).remove();
398400
$scope.getFingerPrintsTime();
399401
}
400402

@@ -502,11 +504,12 @@ app.controller('WiFiController', ['$cookieStore','$scope', 'AnyplaceService', 'G
502504

503505
$scope.showRadioHeatmapRSS();
504506

505-
if($scope.radioHeatmapRSSTimeMode) {
506-
$scope.getFingerPrintsTime()
507+
if( $scope.radioHeatmapRSSTimeMode ){
508+
d3.selectAll("svg > *").remove();
509+
$( "svg" ).remove();
510+
$scope.getFingerPrintsTime();
507511
}
508512

509-
510513
}
511514

512515
if (_APs_IS_ON) {
@@ -546,7 +549,10 @@ app.controller('WiFiController', ['$cookieStore','$scope', 'AnyplaceService', 'G
546549
$scope.showFingerPrints();
547550
if($scope.fingerPrintsTimeMode && !$scope.radioHeatmapRSSTimeMode) {
548551

552+
d3.selectAll("svg > *").remove();
553+
$( "svg" ).remove();
549554
$scope.getFingerPrintsTime();
555+
550556
}
551557
}
552558

@@ -1259,10 +1265,18 @@ app.controller('WiFiController', ['$cookieStore','$scope', 'AnyplaceService', 'G
12591265

12601266
reqObj.lon2 = end.lng()+"";
12611267

1262-
var data = [];
1268+
var promise;
12631269

1264-
var promise = $scope.anyAPI.deleteFingerprints(reqObj);
1270+
if($scope.fingerPrintsTimeMode){
1271+
reqObj.timestampX = userTimeData[0]+"";
12651272

1273+
reqObj.timestampY = userTimeData[1]+"";
1274+
promise= $scope.anyAPI.deleteFingerprintsByTime(reqObj);
1275+
}else{
1276+
promise = $scope.anyAPI.deleteFingerprints(reqObj);
1277+
}
1278+
1279+
var data = [];
12661280

12671281
if (!_HEATMAP_F_IS_ON && !_HEATMAP_RSS_IS_ON)
12681282
_suc("The fingerprints are scheduled to be deleted.");
@@ -2215,7 +2229,7 @@ app.controller('WiFiController', ['$cookieStore','$scope', 'AnyplaceService', 'G
22152229

22162230
var dateToString=timestamps[timestamps.length - 1].date.toString();
22172231
var endDate= new Date(dateToString);
2218-
endDate.setDate(endDate.getDate() + 5);
2232+
endDate.setDate(endDate.getDate() + 15);
22192233

22202234
var charts = [
22212235

server/public/anyplace_architect/index.html

+37-39
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,6 @@
934934
<div ng-dropdown-multiselect="" events="multiuserevents1" options="example8data" selected-model="example8model" extra-settings="example9settings" ng-show="filterByMAN" ></div>
935935
</div>
936936

937-
<!--here-->
938937

939938
</div>
940939

@@ -965,49 +964,48 @@
965964
</div>
966965
</div>
967966

968-
</div>
969-
<!-- Wi-Fi ends -->
970-
<div id="color-bar" ng-show="anyService.radioHeatmapRSSMode" class="">
971-
<ul class="spot">
972-
<span ng-click="hideRSSExcept('g')" title="{{getColorBarTextFor('green')}}" class="A_0" >
973-
<button style="background-color: rgb(78, 212, 25); width: 100px;" id="greenSquares">0 to -60</button>
974-
</span>
975-
<span ng-click="hideRSSExcept('y')" title="{{getColorBarTextFor('yellow')}}" class="A_0" >
976-
<button style="background-color: rgb(255, 255, 0); width: 100px;" id="yellowSquares">-60 to -70</button>
977-
</span>
978-
<span ng-click="hideRSSExcept('o')" title="{{getColorBarTextFor('orange')}}" class="A_0">
979-
<button style="background-color: rgb(255, 165, 0); width: 100px;" id="orangeSquares">-70 to -90</button>
980-
</span>
981-
<span ng-click="hideRSSExcept('p')" title="{{getColorBarTextFor('purple')}}" class="A_0">
982-
<button style="background-color: rgb(189,6,189); width: 100px;" id="purpleSquares">-90 to -100</button>
983-
</span>
984-
<span ng-click="hideRSSExcept('r')" title="{{getColorBarTextFor('red')}}" class="A_0" >
985-
<button style="background-color: rgb(255, 0, 0); width: 100px;" id="redSquares">-100 to -110</button>
986-
</span>
987-
988-
<li style="background-color: rgb(255, 255, 255); width: 50px; text-align: center;">dBm</li>
967+
<div id="color-bar" ng-show="anyService.radioHeatmapRSSMode" class="">
968+
<ul class="spot">
969+
<span ng-click="hideRSSExcept('g')" title="{{getColorBarTextFor('green')}}" class="A_0" >
970+
<button style="background-color: rgb(78, 212, 25); width: 100px;" id="greenSquares">0 to -60</button>
971+
</span>
972+
<span ng-click="hideRSSExcept('y')" title="{{getColorBarTextFor('yellow')}}" class="A_0" >
973+
<button style="background-color: rgb(255, 255, 0); width: 100px;" id="yellowSquares">-60 to -70</button>
974+
</span>
975+
<span ng-click="hideRSSExcept('o')" title="{{getColorBarTextFor('orange')}}" class="A_0">
976+
<button style="background-color: rgb(255, 165, 0); width: 100px;" id="orangeSquares">-70 to -90</button>
977+
</span>
978+
<span ng-click="hideRSSExcept('p')" title="{{getColorBarTextFor('purple')}}" class="A_0">
979+
<button style="background-color: rgb(189,6,189); width: 100px;" id="purpleSquares">-90 to -100</button>
980+
</span>
981+
<span ng-click="hideRSSExcept('r')" title="{{getColorBarTextFor('red')}}" class="A_0" >
982+
<button style="background-color: rgb(255, 0, 0); width: 100px;" id="redSquares">-100 to -110</button>
983+
</span>
984+
985+
<li style="background-color: rgb(255, 255, 255); width: 50px; text-align: center;">dBm</li>
986+
987+
<button style="width: 50px;">
988+
<a data-toggle="modal" data-target="#myModal_2">
989+
<i class="fa fa-info-circle"></i>
990+
</a>
991+
</button>
992+
993+
</ul>
994+
</div>
995+
<div id="time-bar" ng-show="anyService.fingerPrintsTimeMode || anyService.radioHeatmapRSSTimeMode" class="" >
996+
<div id="charts">
997+
<div id="date-chart" class="chart">
998+
<div class="title">Date</div>
999+
</div>
1000+
</div>
9891001

990-
<button style="width: 50px;">
991-
<a data-toggle="modal" data-target="#myModal_2">
992-
<i class="fa fa-info-circle"></i>
993-
</a>
994-
</button>
1002+
<script src="libs/crossfilter.v1.min.js"></script>
1003+
<script src="libs/d3.v3.min.js"></script>
9951004

996-
</ul>
997-
</div>
998-
<div id="wrapper">
999-
<div id="time-bar" ng-show="anyService.fingerPrintsTimeMode || anyService.radioHeatmapRSSTimeMode" class="" >
1000-
<div id="charts">
1001-
<div id="date-chart" class="chart">
1002-
<div class="title">Date</div>
1003-
</div>
10041005
</div>
10051006

1006-
<script src="libs/crossfilter.v1.min.js"></script>
1007-
<script src="libs/d3.v3.min.js"></script>
1008-
1009-
</div>
10101007
</div>
1008+
<!-- Wi-Fi ends -->
10111009

10121010
</div>
10131011

server/public/anyplace_architect/scripts/AnyplaceAPI.js

+17
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ AnyplaceAPI.Mapping.APs_URL = AnyplaceAPI.FULL_SERVER + AnyplaceAPI.Mapping.APs;
5959
AnyplaceAPI.Mapping.FINGERPRINTS_DELETE = "/position/radio/delete";
6060
AnyplaceAPI.Mapping.FINGERPRINTS_DELETE_URL = AnyplaceAPI.FULL_SERVER + AnyplaceAPI.Mapping.FINGERPRINTS_DELETE;
6161

62+
AnyplaceAPI.Mapping.FINGERPRINTS_DELETE_TIME = "/position/radio/delete/time";
63+
AnyplaceAPI.Mapping.FINGERPRINTS_DELETE_TIME_URL = AnyplaceAPI.FULL_SERVER + AnyplaceAPI.Mapping.FINGERPRINTS_DELETE_TIME;
64+
6265
AnyplaceAPI.Mapping.GET_APS_IDS="/position/radio/aps_ids";
6366
AnyplaceAPI.Mapping.GET_APS_IDS_URL=AnyplaceAPI.FULL_SERVER + AnyplaceAPI.Mapping.GET_APS_IDS;
6467

@@ -333,6 +336,20 @@ app.factory('AnyplaceAPIService', ['$http', '$q', 'formDataObject', function ($h
333336
return data;
334337
});
335338

339+
};
340+
341+
apiService.deleteFingerprintsByTime = function (json_req) {
342+
//alert( "make the request: " + json_req );
343+
return $http({
344+
method: "POST",
345+
url: AnyplaceAPI.Mapping.FINGERPRINTS_DELETE_TIME_URL,
346+
data: json_req
347+
}).success(function (data, status) {
348+
return data;
349+
}).error(function (data, status) {
350+
return data;
351+
});
352+
336353
};
337354
//end new marileni
338355

0 commit comments

Comments
 (0)