Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
8d2e0e34
Commit
8d2e0e34
authored
Nov 29, 2018
by
Julian Zobel
Browse files
JSON Attraction Generator now takes in an upper limit for attraction points
parent
6906943a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/attraction/JSONAttractionGenerator.java
View file @
8d2e0e34
...
...
@@ -36,6 +36,7 @@ import de.tud.kom.p2psim.impl.topology.movement.modularosm.GPSCalculation;
import
de.tud.kom.p2psim.impl.topology.util.PositionVector
;
import
de.tudarmstadt.maki.simonstrator.api.Binder
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint
;
import
de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor
;
/**
* Generates attraction points out of real data from osm
...
...
@@ -43,13 +44,18 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Attraction
*
* @author Martin Hellwig
* @version 1.0, 02.07.2015
*
* Added an upper limit for the number of attraction points. Use 0 to allow all APs in the JSON file.
* @author Julian Zobel
* @version 1.1, November 2018
*
*
*/
public
class
JSONAttractionGenerator
implements
IAttractionGenerator
{
private
PositionVector
worldDimensions
;
private
List
<
AttractionPoint
>
attractionPoints
;
private
int
numberOfAttractionPoints
;
private
String
placementJsonFile
;
private
double
latLeft
;
//Values from -90 to 90; always smaller than latRight
private
double
latRight
;
//Values from -90 to 90
...
...
@@ -61,11 +67,12 @@ public class JSONAttractionGenerator implements IAttractionGenerator {
* Sample-query for "bar"-POIs in Darmstadt (Bounding Box from [49.4813, 8.5590] to [49.9088, 8,7736]:
http://overpass-api.de/api/interpreter?data=%5Bout:json%5D;node%5Bamenity=bar%5D%2849%2E4813%2C8%2E5590%2C49%2E9088%2C8%2E7736%29%3Bout%3B
*/
public
JSONAttractionGenerator
()
{
@XMLConfigurableConstructor
({
"numberOfAttractionPoints"
})
public
JSONAttractionGenerator
(
int
numberOfAttractionPoints
)
{
this
.
worldDimensions
=
Binder
.
getComponentOrNull
(
Topology
.
class
)
.
getWorldDimensions
();
attractionPoints
=
new
LinkedList
<
AttractionPoint
>();
this
.
numberOfAttractionPoints
=
numberOfAttractionPoints
;
latLeft
=
GPSCalculation
.
getLatLower
();
latRight
=
GPSCalculation
.
getLatUpper
();
lonLeft
=
GPSCalculation
.
getLonLeft
();
...
...
@@ -105,7 +112,16 @@ public class JSONAttractionGenerator implements IAttractionGenerator {
}
if
(
allPOI
!=
null
)
{
for
(
int
i
=
0
;
i
<
allPOI
.
length
();
i
++)
{
int
limit
=
0
;
if
(
numberOfAttractionPoints
==
0
)
{
limit
=
allPOI
.
length
();
}
else
{
limit
=
numberOfAttractionPoints
;
}
for
(
int
i
=
0
;
i
<
limit
;
i
++)
{
try
{
String
barname
=
allPOI
.
getJSONObject
(
i
).
getJSONObject
(
"tags"
).
getString
(
"name"
);
double
lat
=
allPOI
.
getJSONObject
(
i
).
getDouble
(
"lat"
);
...
...
@@ -132,5 +148,9 @@ public class JSONAttractionGenerator implements IAttractionGenerator {
public
void
setPlacementJsonFile
(
String
placementJsonFile
)
{
this
.
placementJsonFile
=
placementJsonFile
;
//System.out.println(placementJsonFile);
if
(
attractionPoints
.
isEmpty
())
{
this
.
getAttractionPoints
();
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment