Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(charging): provide the charging stations within a certain area #446

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ buildNumber.properties
*.log
credentials.cached
*.lcs
.tiles
.tiles
Binary file added .tileCache/grid/tiles.index
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ public ApplicationAmbassador(AmbassadorParameter ambassadorParameter) {
}

if (SimulationKernel.SimulationKernel.chargingStationIndex == null) {
// use same bucketsize as TrafficLightTree (see: CPercetion.java) (bucketsize := number of direct children per tree node)
ChargingStationIndex chargingStationIndex = new ChargingStationIndex();
SimulationKernel.SimulationKernel.setChargingStationIndex(chargingStationIndex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public ChargingStationIndex() {

/**
* Adds a Charging Station to the tree.
* Be sure to add {@link ChargingStationData} using updateChargingStation(ChargingStationData chargingStationData).
* <p>The CS is inserted into the tree when it is queried (e.g. getChargingStationsInCircle(...) or
* getNumberOfChargingStations(...))</p>
* Be sure to add {@link ChargingStationData} using {@link ChargingStationIndex#updateChargingStation(ChargingStationData)}.
* <p>The CS is inserted into the tree when it is queried (e.g. {@link ChargingStationIndex#getChargingStationsInCircle(GeoCircle)}or
* {@link ChargingStationIndex#getNumberOfChargingStations()}</p>
*
* @param id ID of the ChargingStation
* @param position Position of the ChargingStation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

package org.eclipse.mosaic.fed.application.ambassador;

import static org.eclipse.mosaic.lib.geo.GeoPoint.latLon;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.fail;
Expand All @@ -29,7 +28,6 @@

import org.eclipse.mosaic.fed.application.ambassador.eventresources.StartApplications;
import org.eclipse.mosaic.fed.application.ambassador.simulation.communication.ReceivedAcknowledgement;
import org.eclipse.mosaic.fed.application.ambassador.simulation.electric.objects.ChargingStationObject;
import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.CentralNavigationComponent;
import org.eclipse.mosaic.fed.application.ambassador.simulation.perception.CentralPerceptionComponent;
import org.eclipse.mosaic.fed.application.app.TestAgentApplication;
Expand All @@ -53,11 +51,9 @@
import org.eclipse.mosaic.interactions.traffic.VehicleTypesInitialization;
import org.eclipse.mosaic.interactions.traffic.VehicleUpdates;
import org.eclipse.mosaic.interactions.vehicle.VehicleRouteRegistration;
import org.eclipse.mosaic.lib.geo.GeoCircle;
import org.eclipse.mosaic.lib.geo.GeoPoint;
import org.eclipse.mosaic.lib.junit.GeoProjectionRule;
import org.eclipse.mosaic.lib.junit.IpResolverRule;
import org.eclipse.mosaic.lib.objects.electricity.ChargingStationData;
import org.eclipse.mosaic.lib.objects.traffic.InductionLoopInfo;
import org.eclipse.mosaic.lib.objects.traffic.LaneAreaDetectorInfo;
import org.eclipse.mosaic.lib.objects.trafficlight.TrafficLightGroup;
Expand All @@ -69,8 +65,6 @@
import org.eclipse.mosaic.lib.objects.vehicle.VehicleData;
import org.eclipse.mosaic.lib.objects.vehicle.VehicleRoute;
import org.eclipse.mosaic.lib.objects.vehicle.VehicleType;
import org.eclipse.mosaic.lib.transform.GeoProjection;
import org.eclipse.mosaic.lib.transform.Wgs84Projection;
import org.eclipse.mosaic.lib.util.junit.TestUtils;
import org.eclipse.mosaic.lib.util.scheduling.Event;
import org.eclipse.mosaic.rti.TIME;
Expand All @@ -89,7 +83,6 @@
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.stubbing.Answer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static ChargingStationRegistration createChargingStationRegistration(String id,
id,
"group_0",
getApplications(withApp, TestChargingStationApplication.class),
GeoPoint.lonLat(52.520008, 13.404954),
GeoPoint.lonLat(0, 0),
Collections.emptyList()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,20 @@
import org.eclipse.mosaic.lib.objects.electricity.ChargingStationData;
import org.eclipse.mosaic.lib.objects.electricity.ChargingType;

import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class ChargingStationIndexTest {
GeoPoint position = latLon(52.5, 13.4);
ChargingStationIndex chargingStationIndex;
private final GeoPoint position = GeoPoint.latLon(52.5, 13.4);
private ChargingStationIndex chargingStationIndex;

@Rule
public GeoProjectionRule projectionRule = new GeoProjectionRule(GeoPoint.latLon(52.5, 13.4));

@Before
public void before() {
chargingStationIndex = new ChargingStationIndex();
Expand All @@ -53,11 +52,11 @@ private void registerChargingStations(int amount) {
}
}

private List<ChargingSpot> getChargingSpots(int amount, String cs_id) {
private List<ChargingSpot> createChargingSpotList(int amount, String chargingStation_id) {
List<ChargingSpot> spots = new ArrayList<>();
// create ChargingSpots
for (int i = 0; i < amount; i++) {
String spot_id = "charging_spot" + cs_id + "_" + i;
String spot_id = "charging_spot" + chargingStation_id + "_" + i;
ChargingSpot spot = new ChargingSpot(spot_id, ChargingType.DC, 100.0, 100.0);
spots.add(spot);
}
Expand All @@ -70,7 +69,7 @@ public void addChargingStation_ChargingStationIndex() {
registerChargingStations(3);

// add initial data to charging stations
List<ChargingSpot> spots_0 = getChargingSpots(3, "cs_0");
List<ChargingSpot> spots_0 = createChargingSpotList(3, "cs_0");
chargingStationIndex.updateChargingStation(new ChargingStationData(0, "cs_0", position, spots_0));
chargingStationIndex.updateChargingStation(new ChargingStationData(0, "cs_1", position, new ArrayList<>()));
chargingStationIndex.updateChargingStation(new ChargingStationData(0, "cs_2", position, new ArrayList<>()));
Expand All @@ -92,7 +91,7 @@ public void update_ChargingStationIndex() {
registerChargingStations(1);

// add initial data to charging stations
List<ChargingSpot> spots_0 = getChargingSpots(3, "cs_0");
List<ChargingSpot> spots_0 = createChargingSpotList(3, "cs_0");
chargingStationIndex.updateChargingStation(new ChargingStationData(0, "cs_0", position, spots_0));

// query the index to initialize the tree
Expand Down