Commit facab057 authored by Petyo Bogdanov Ilov's avatar Petyo Bogdanov Ilov

Initial commit in GitHub

parent 5fc65793
/target/*
.settings/*
.project
.classpath
.directory
/target/
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>montisim</artifactId>
<groupId>montisim</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>montisim</groupId>
<artifactId>server-communication</artifactId>
<name>server-communication</name>
<version>1.0.0</version>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer>
<mainClass>package rwth.server.extensions.ZoneExt</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
<id>jboss-public-repository</id>
<name>JBoss Public Maven Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>in-project</id>
<name>In Project Repo</name>
<url>file://${project.basedir}/libs</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<smartfox.version>2.13</smartfox.version>
<log4j.version>1.2.17</log4j.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<montisim.version>1.0.0</montisim.version>
</properties>
</project>
map=/extensions/AllInOne/aachen.osm
mapName=Aachen
flat_map=1
weather_rain=0
map_overlap=1000
map_sector_width=10000
map_sector_length=10000
max_sector_sims=50
max_limbo=20
renderFlequency=1
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>montisim</artifactId>
<groupId>montisim</groupId>
<version>1.0.0</version>
</parent>
<artifactId>server</artifactId>
<groupId>montisim</groupId>
<version>1.0.0</version>
<name>server</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<smartfox.version>2.13</smartfox.version>
<log4j.version>1.2.17</log4j.version>
<montisim.version>1.0.0</montisim.version>
</properties>
<!-- ================================================================================ -->
<!-- External additional maven repositories -->
<!-- ================================================================================ -->
<repositories>
<repository>
<id>jboss-public-repository</id>
<name>JBoss Public Maven Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
<!-- In Project (temporal) -->
<repository>
<id>in-project</id>
<name>In Project Repo</name>
<url>file://${project.basedir}/libs</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- SFS -->
<dependency>
<groupId>sfs</groupId>
<artifactId>sfs2x</artifactId>
<version>${smartfox.version}</version>
</dependency>
<dependency>
<groupId>sfs</groupId>
<artifactId>sfs2x-core</artifactId>
<version>${smartfox.version}</version>
</dependency>
<!-- MontiSim -->
<dependency>
<groupId>montisim</groupId>
<artifactId>commons</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>montisim-controller</groupId>
<artifactId>library</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>montisim-controller</groupId>
<artifactId>control</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>montisim-controller</groupId>
<artifactId>navigation</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>montisim-simulation</groupId>
<artifactId>environment</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>montisim-simulation</groupId>
<artifactId>vehicle</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>montisim-simulation</groupId>
<artifactId>sensors</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>montisim-simulation</groupId>
<artifactId>network</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>montisim-simulation</groupId>
<artifactId>simulator</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<!-- One-Jar plugin -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>package rwth.server.extensions.ZoneExt</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:3.8.1" level="project" />
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
<orderEntry type="library" name="Maven: sfs:sfs2x:2.13" level="project" />
<orderEntry type="library" name="Maven: sfs:sfs2x-core:2.13" level="project" />
<orderEntry type="module" module-name="application-layer" />
<orderEntry type="module" module-name="environment" />
<orderEntry type="module" module-name="util" />
<orderEntry type="library" name="Maven: jfree:jfreechart:1.0.13" level="project" />
<orderEntry type="library" name="Maven: jfree:jcommon:1.0.16" level="project" />
<orderEntry type="module" module-name="commons" />
<orderEntry type="library" name="Maven: de.topobyte:osm4j-core:0.0.18" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:adt-multicollections:0.0.3" level="project" />
<orderEntry type="library" name="Maven: net.sf.trove4j:trove4j:3.0.3" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:osm4j-utils:0.0.22" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:large-scale-file-io:0.0.1" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:commons-cli-helper:0.0.3" level="project" />
<orderEntry type="library" name="Maven: commons-cli:commons-cli:1.3.1" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:melon-io:0.0.1" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:18.0" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:osm4j-xml:0.0.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.3.2" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:dynsax:0.0.1" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.7" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:osm4j-pbf:0.0.7" level="project" />
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:2.6.1" level="project" />
<orderEntry type="library" name="Maven: net.jpountz.lz4:lz4:1.3.0" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:osm4j-tbo:0.0.9" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:compact-io:0.0.5" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:osm4j-geometry:0.0.14" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:jts-utils:0.0.4" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:jsi:1.1.0" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:adt-graph:0.0.1" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:adt-geo:0.0.2" level="project" />
<orderEntry type="library" name="Maven: com.vividsolutions:jts:1.13" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:jts2awt:0.0.1" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:jgs:0.0.1" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:mercator-image:0.0.1" level="project" />
<orderEntry type="library" name="Maven: de.topobyte:geomath:0.0.1" level="project" />
<orderEntry type="library" name="Maven: org.wololo:jts2geojson:0.6.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.6.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.6.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.6.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-compress:1.8" level="project" />
<orderEntry type="library" name="Maven: org.tukaani:xz:1.5" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.6.1" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-log4j12:1.6.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" name="Maven: net.imagej:ij:1.51j" level="project" />
<orderEntry type="module-library">
<library name="Maven: com.sun:tools:1.4.2">
<CLASSES>
<root url="jar:///usr/lib/jvm/java-8-openjdk-amd64/jre/../lib/tools.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module" module-name="vehicle" />
<orderEntry type="module" module-name="library" />
<orderEntry type="module" module-name="simulator" />
<orderEntry type="module" module-name="sensors" />
<orderEntry type="library" name="Maven: com.jhlabs:filters:2.0.235-1" level="project" />
<orderEntry type="module" module-name="network" />
<orderEntry type="module" module-name="navigation" />
<orderEntry type="module" module-name="control" />
</component>
</module>
\ No newline at end of file
package rwth.server.bo;
import java.util.List;
import rwth.server.dao.EnvNodeDao;
import simulation.environment.visualisationadapter.interfaces.EnvNode;
public class EnvNodeBO {
private EnvNodeDao enDao;
public EnvNodeBO() {
this.enDao = new EnvNodeDao();
}
public Integer add(Number x, Number y, Number z, long osmId, int objId) {
return enDao.add(x.doubleValue(), y.doubleValue(), z.doubleValue(), osmId, objId, false);
}
public Integer add(Number x, Number y, Number z, long osmId, int objId, boolean isIntersection) {
return enDao.add(x.doubleValue(), y.doubleValue(), z.doubleValue(), osmId, objId, isIntersection);
}
public List<EnvNode> getNodes(long objOsmId) {
return enDao.getForOsm(objOsmId);
}
}
package rwth.server.bo;
import java.util.List;
import rwth.server.dao.EnvObjectDao;
import rwth.server.dao.StreetDao;
import simulation.environment.visualisationadapter.interfaces.EnvBounds;
import simulation.environment.visualisationadapter.interfaces.EnvObject;
import simulation.environment.visualisationadapter.interfaces.EnvStreet;
import simulation.environment.visualisationadapter.interfaces.EnvTag;
public class EnvObjectBO {
private EnvObjectDao eoDao;
private StreetDao sDao;
public EnvObjectBO() {
this.eoDao = new EnvObjectDao();
this.sDao = new StreetDao();
}
public Integer add(EnvTag tag, long osmId, int mapId) {
return eoDao.add(tag, osmId, mapId);
}
public EnvObject get(long osmId, int mapId) {
return eoDao.getByOsmId(osmId, mapId);
}
public List<? extends EnvObject> getAll(EnvBounds bounds, int mapId) {
return eoDao.getByBounds(bounds, mapId);
}
/**
* Adds EnvObject and Street records at once
*
* @param objTag - object tag
* @param osmId - object osmId
* @param mapId - map Id
* @param speedLimit - street speed limit
* @param streetWidth - street width
* @param isOneWay - is street one way
* @return -object id
*/
public Integer addStreet(EnvTag objTag, long osmId, int mapId, Number speedLimit, Number streetWidth, boolean isOneWay) {
Integer objId = this.add(objTag, osmId, mapId);
sDao.add(objId, speedLimit.doubleValue(), streetWidth.doubleValue(), isOneWay);
return objId;
}
public EnvStreet getStreet(long osmId, int mapId) {
return sDao.getByOsmId(osmId, mapId);
}
public List<EnvStreet> getAllStreets(EnvBounds bounds, int mapId) {
return sDao.getByBounds(bounds, mapId);
}
}
package rwth.server.bo;
import rwth.server.dao.MapDao;
public class MapBO {
private MapDao mDao;
public MapBO() {
this.mDao = new MapDao();
}
public Integer add(String name, String srcFile) {
return mDao.add(name, srcFile);
}
public Integer getId(String name) {
return mDao.getId(name);
}
public String getSource(String name) {
return mDao.getSource(name);
}
}
package rwth.server.bo;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.smartfoxserver.v2.extensions.ExtensionLogLevel;
import rwth.server.bo.util.Logger;
import rwth.server.dao.AreaDao;
import rwth.server.dao.SectorDao;
import rwth.server.pojo.MapArea;
import rwth.server.pojo.MapSector;
import simulation.environment.visualisationadapter.interfaces.EnvBounds;
import simulation.environment.visualisationadapter.interfaces.EnvObject;
public class SectorBO {
private Logger console;
private SectorDao sDao;
private AreaDao aDao;
public SectorBO() {
this.console = Logger.getInstance();
this.sDao = new SectorDao();
this.aDao = new AreaDao();
}
public Integer addSector(int mapId, int areaId) {
return sDao.add(mapId, areaId);
}
public Integer addArea(double minX, double maxX, double minY, double maxY, double minZ, double maxZ) {
return aDao.add(minX, maxX, minY, maxY, minZ, maxZ);
}
public List<MapSector> getSectors(int mapId) {
try {
List<MapSector> sectorsList = sDao.getAll(mapId);
for(MapSector sector : sectorsList) {
MapArea area = aDao.get(sector.getArea().getId());
sector.setArea(area);
sector.setOverlappedAreas(getOverlappedAreas(sector, sectorsList));
}
return sectorsList;
} catch (Exception e) {
this.console.trace(ExtensionLogLevel.ERROR, e);
}
return null;
}
public Integer addOverlappedArea(int sectorA, int sectorB, int areaId) {
return sDao.addOverlapArea(sectorA, sectorB, areaId);
}
private Map<MapArea, MapSector> getOverlappedAreas(MapSector sector, List<MapSector> sectors) {
Map<MapArea, MapSector> overlappedAreas = new HashMap<MapArea, MapSector>();
//id of sector (not current one), id of overlapped area
Map<Integer, Integer> sectAreaMap = sDao.getOverlappedSectors(sector.getId());
try {
for(Integer sectId : sectAreaMap.keySet()) {
//keep the two-way binding
for(MapSector sect : sectors) {
if(sect.getId() == sectId) {
overlappedAreas.put(aDao.get(sectAreaMap.get(sectId)), sect);
break;
}
}
}
return overlappedAreas;
} catch (Exception e) {
this.console.trace(ExtensionLogLevel.ERROR, e);
}
return null;
}
public List<EnvObject> getObjects(EnvBounds bounds, int mapId) {
return sDao.getObjects(bounds, mapId);
}
public List<EnvObject> getObjects(int sectorId, int mapId) {
EnvBounds bounds = getBounds(sectorId); //get sector bounds
return getObjects(bounds, mapId);
}
public EnvBounds getBounds(int areaId) {
return aDao.getBounds(areaId);
}
}
package rwth.server.bo;
import java.util.List;
import rwth.server.dao.SimTrackDao;
import rwth.server.pojo.SimulationTrack;
public class SimTrackBO {
private SimTrackDao dao;
public SimTrackBO() {
this.dao = new SimTrackDao();
}
public Integer add(String name, int mapId, double startX, double startY, double endX, double endY) {
return dao.add(name, mapId, startX, startY, endX, endY);
}
public List<SimulationTrack> getAll(int mapId) {
return dao.getAll(mapId);
}
public SimulationTrack get(Integer id) {
return dao.get(id);
}
}
package rwth.server.bo;
import com.smartfoxserver.bitswarm.sessions.ISession;
import com.smartfoxserver.v2.api.ISFSApi;
import rwth.server.bo.util.ApiManager;
import rwth.server.dao.UsersDao;
public class UsersBO {
private UsersDao uDao;
private ISFSApi api = ApiManager.getInstance().getApi();
public UsersBO() {
this.uDao = new UsersDao();
}
public boolean exists(String username, String password, ISession session) {
String dbPwd = uDao.getPassword(username);
//no password for specified user has been found or an exception has been risen
if(dbPwd == null) return false;
return api.checkSecurePassword(session, dbPwd, password);
}
public boolean register(String name, String password) {
return uDao.add(name, password) > 0; //successful registration, when the user becomes an id
}
}
package rwth.server.bo;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.smartfoxserver.v2.extensions.ExtensionLogLevel;
import rwth.server.bo.util.Logger;
import rwth.server.pojo.MapArea;
import rwth.server.pojo.MapSector;
import simulation.environment.World;
import simulation.environment.visualisationadapter.implementation.Bounds2D;
import simulation.environment.visualisationadapter.implementation.EnvironmentContainer2D;
import simulation.environment.visualisationadapter.interfaces.Building;
import simulation.environment.visualisationadapter.interfaces.EnvBounds;
import simulation.environment.visualisationadapter.interfaces.EnvNode;
import simulation.environment.visualisationadapter.interfaces.EnvStreet;
import simulation.environment.visualisationadapter.interfaces.VisualisationEnvironmentContainer;
public class WorldBuilder {
private Logger console;
private static WorldBuilder instance;
private SectorBO sectBo;
private EnvObjectBO eoBo;
private EnvNodeBO enBo;
private WorldBuilder() {
this.console = Logger.getInstance();
this.sectBo = new SectorBO();
this.eoBo = new EnvObjectBO();
this.enBo = new EnvNodeBO();