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
bfa3abc0
Commit
bfa3abc0
authored
Jul 10, 2015
by
Martin Hellwig
Browse files
Uses now the osm-street data to navigate the nodes from and to its locations
parent
df17fe5a
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/local/RealWorldMovementPoints.java
0 → 100644
View file @
bfa3abc0
/*
* Copyright (c) 2005-2010 KOM Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tud.kom.p2psim.impl.topology.movement.local
;
import
com.graphhopper.util.PointList
;
import
de.tud.kom.p2psim.impl.topology.PositionVector
;
public
class
RealWorldMovementPoints
{
private
PositionVector
start
;
private
PositionVector
destination
;
private
PointList
pointList
;
private
int
actualIndex
;
public
RealWorldMovementPoints
(
PositionVector
start
,
PositionVector
destination
,
PointList
pointList
,
int
actualIndex
)
{
this
.
start
=
start
;
this
.
destination
=
destination
;
this
.
pointList
=
pointList
;
this
.
actualIndex
=
actualIndex
;
}
public
PositionVector
getStart
()
{
return
start
;
}
public
void
setStart
(
PositionVector
start
)
{
this
.
start
=
start
;
}
public
PositionVector
getDestination
()
{
return
destination
;
}
public
void
setDestination
(
PositionVector
destination
)
{
this
.
destination
=
destination
;
}
public
PointList
getPointList
()
{
return
pointList
;
}
public
void
setPointList
(
PointList
pointList
)
{
this
.
pointList
=
pointList
;
}
public
int
getActualIndex
()
{
return
this
.
actualIndex
;
}
}
src/de/tud/kom/p2psim/impl/topology/movement/local/RealWorldStreetsMovement.java
View file @
bfa3abc0
...
...
@@ -20,17 +20,9 @@
package
de.tud.kom.p2psim.impl.topology.movement.local
;
import
java.io.FileInputStream
;
import
java.io.InputStream
;
import
java.util.HashMap
;
import
java.util.Locale
;
import
javax.xml.stream.XMLInputFactory
;
import
javax.xml.stream.XMLStreamConstants
;
import
javax.xml.stream.XMLStreamException
;
import
javax.xml.stream.XMLStreamReader
;
import
org.openstreetmap.osmosis.osmbinary.Osmformat
;
import
com.graphhopper.GHRequest
;
import
com.graphhopper.GHResponse
;
import
com.graphhopper.GraphHopper
;
...
...
@@ -56,6 +48,8 @@ public class RealWorldStreetsMovement extends AbstractLocalMovementStrategy {
private
GraphHopper
hopper
;
private
boolean
init
=
false
;
private
static
HashMap
<
Integer
,
RealWorldMovementPoints
>
movementPoints
=
new
HashMap
<>();
private
String
osmFileLocation
;
//use pbf-format, because osm-format causes problems (xml-problems)
private
String
graphFolderFiles
;
private
String
movementType
;
//car, bike or foot
...
...
@@ -64,6 +58,8 @@ public class RealWorldStreetsMovement extends AbstractLocalMovementStrategy {
private
double
latRight
;
//Values from -90 to 90
private
double
lonLeft
;
//Values from -180 to 180; Always smaller than lonRight
private
double
lonRight
;
//Values from -180 to 180
private
double
maxDistanceNextPoint
;
//This defines the maximum distance to the next point in line;
//if the distance is smaller than the given one, the node will choose the next point in the list
public
RealWorldStreetsMovement
()
{
this
.
worldDimensions
=
Topology
.
getWorldDimension
();
...
...
@@ -87,24 +83,36 @@ public class RealWorldStreetsMovement extends AbstractLocalMovementStrategy {
if
(
destination
.
getDistance
(
comp
.
getRealPosition
())
<
getMovementSpeed
(
comp
))
{
newPosition
=
destination
.
clone
();
}
else
{
//if not set already for this node or new destination is different than last one
PointList
pointList
;
if
(!
movementPoints
.
containsKey
(
comp
.
hashCode
())
||
destination
.
distanceTo
(
movementPoints
.
get
(
comp
.
hashCode
()).
getDestination
())
>
1.0
)
{
double
[]
startPosition
=
transformOwnWorldWindowToGPS
(
comp
.
getRealPosition
().
getX
(),
comp
.
getRealPosition
().
getY
());
double
[]
destinationPosition
=
transformOwnWorldWindowToGPS
(
destination
.
getX
(),
destination
.
getY
());
GHRequest
req
=
new
GHRequest
(
startPosition
[
0
],
startPosition
[
1
],
destinationPosition
[
0
],
destinationPosition
[
1
]).
setWeighting
(
navigationalType
).
setVehicle
(
movementType
).
setLocale
(
Locale
.
GERMANY
);
GHResponse
rsp
=
hopper
.
route
(
req
);
pointList
=
rsp
.
getPoints
();
movementPoints
.
put
(
comp
.
hashCode
(),
new
RealWorldMovementPoints
(
comp
.
getRealPosition
(),
destination
,
pointList
,
0
));
}
else
{
pointList
=
movementPoints
.
get
(
comp
.
hashCode
()).
getPointList
();
}
double
[]
startPosition
=
transformOwnWorldWindowToGPS
(
comp
.
getRealPosition
().
getX
(),
comp
.
getRealPosition
().
getY
());
double
[]
destinationPosition
=
transformOwnWorldWindowToGPS
(
destination
.
getX
(),
destination
.
getY
());
GHRequest
req
=
new
GHRequest
(
startPosition
[
0
],
startPosition
[
1
],
destinationPosition
[
0
],
destinationPosition
[
1
]).
setWeighting
(
navigationalType
).
setVehicle
(
movementType
).
setLocale
(
Locale
.
GERMANY
);
GHResponse
rsp
=
hopper
.
route
(
req
);
PointList
pointList
=
rsp
.
getPoints
();
int
bla
=
0
;
int
actualIndex
=
movementPoints
.
get
(
comp
.
hashCode
()).
getActualIndex
();
int
i
=
0
;
for
(
GHPoint3D
temp
:
pointList
)
{
PositionVector
nextPoint
=
transformGPSWindowToOwnWorld
(
temp
.
getLat
(),
temp
.
getLon
());
newPosition
=
comp
.
getRealPosition
().
moveStep
(
nextPoint
,
10
*
getMovementSpeed
(
comp
));
bla
++;
if
(
bla
==
2
)
break
;
if
(
i
==
actualIndex
)
{
PositionVector
nextPoint
=
transformGPSWindowToOwnWorld
(
temp
.
getLat
(),
temp
.
getLon
());
newPosition
=
comp
.
getRealPosition
().
moveStep
(
nextPoint
,
getMovementSpeed
(
comp
));
if
(
nextPoint
.
distanceTo
(
comp
.
getRealPosition
())
<
maxDistanceNextPoint
)
actualIndex
++;
}
i
++;
}
//newPosition = comp.getRealPosition().moveStep(destination, getMovementSpeed(comp
));
movementPoints
.
put
(
comp
.
hashCode
(),
new
RealWorldMovementPoints
(
movementPoints
.
get
(
comp
.
hashCode
()).
getStart
(),
destination
,
pointList
,
actualIndex
));
}
return
new
Left
<
PositionVector
,
Boolean
>(
newPosition
);
}
...
...
@@ -165,4 +173,8 @@ public class RealWorldStreetsMovement extends AbstractLocalMovementStrategy {
public
void
setLonRight
(
double
lonRight
)
{
this
.
lonRight
=
lonRight
;
}
public
void
setMaxDistanceNextPoint
(
double
maxDistanceNextPoint
)
{
this
.
maxDistanceNextPoint
=
maxDistanceNextPoint
;
}
}
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/attraction/JSONAttractionGenerator.java
View file @
bfa3abc0
...
...
@@ -108,7 +108,8 @@ public class JSONAttractionGenerator implements IAttractionGenerator {
String
barname
=
allPOI
.
getJSONObject
(
i
).
getJSONObject
(
"tags"
).
getString
(
"name"
);
double
lat
=
allPOI
.
getJSONObject
(
i
).
getDouble
(
"lat"
);
double
lon
=
allPOI
.
getJSONObject
(
i
).
getDouble
(
"lon"
);
attractionPoints
.
add
(
new
AttractionPoint
(
transformGPSWindowToOwnWorld
(
lat
,
lon
),
barname
));
if
(
lat
>
latLeft
&&
lat
<
latRight
&&
lon
>
lonLeft
&&
lon
<
lonRight
)
attractionPoints
.
add
(
new
AttractionPoint
(
transformGPSWindowToOwnWorld
(
lat
,
lon
),
barname
));
}
catch
(
JSONException
e
)
{
//This bar had no name defined, so there was an error. Not so bad
...
...
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/transition/SocialTransitionStrategy.java
View file @
bfa3abc0
...
...
@@ -41,7 +41,7 @@ import de.tud.kom.p2psim.api.topology.social.SocialView;
import
de.tud.kom.p2psim.impl.simengine.Simulator
;
import
de.tud.kom.p2psim.impl.topology.PositionVector
;
import
de.tud.kom.p2psim.impl.topology.Topology
;
import
de.tud.kom.p2psim.impl.topology.movement.modular.attraction.AttractionPoint
;
import
de.tud.kom.p2psim.impl.topology.movement.modular
osm
.attraction.AttractionPoint
;
import
de.tudarmstadt.maki.simonstrator.api.Event
;
import
de.tudarmstadt.maki.simonstrator.api.EventHandler
;
import
de.tudarmstadt.maki.simonstrator.api.Randoms
;
...
...
@@ -77,7 +77,7 @@ import de.tudarmstadt.maki.simonstrator.api.Randoms;
* @author Christoph Muenker
* @version 1.0, 02.07.2013
*/
public
class
SocialTransitionStrategy
implements
TransitionStrategy
,
public
class
SocialTransitionStrategy
implements
I
TransitionStrategy
,
EventHandler
{
private
String
socialId
=
null
;
...
...
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