本文整理匯總了Java中dk.dma.enav.model.geometry.Area類的典型用法代碼示例。如果您正苦於以下問題:Java Area類的具體用法?Java Area怎麽用?Java Area使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Area類屬於dk.dma.enav.model.geometry包,在下文中一共展示了Area類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadDummyCells
import dk.dma.enav.model.geometry.Area; //導入依賴的package包/類
/**
* Simulate loading of cells from the repository, but actually generate an artificial pattern of cells with data.
* This method is not for production use, but intended for test and development only.
*
* @param grid the grid system to use
* @param area the area - not used; included for signature compliance.
* @return
*/
private Set<CellWrapper> loadDummyCells(Grid grid, Area area) {
Set<CellWrapper> cells = new LinkedHashSet<>();
for (double lon = 12.0; lon < 12.50; lon += 0.05) {
for (double lat = 56.0; lat < 56.50; lat += 0.05) {
ShipTypeAndSizeStatisticData statistic1Data = ShipTypeAndSizeStatisticData.create();
statistic1Data.setValue((short) 1, (short) 1, "stat1", (Integer) 7);
ShipTypeAndSizeStatisticData statistic2Data = ShipTypeAndSizeStatisticData.create();
statistic2Data.setValue((short) 1, (short) 1, "statA", (Integer) 9);
statistic2Data.setValue((short) 1, (short) 2, "statA", (Integer) 8);
statistic2Data.setValue((short) 2, (short) 1, "statA", (Integer) 7);
Position nw = Position.create(lat+0.02, lon-0.02);
Position se = Position.create(lat-0.02, lon+0.02);
BoundingBox boundingBoxOfCell = BoundingBox.create(nw, se, CoordinateSystem.CARTESIAN);
Cell cell = grid.getCell(lat, lon);
CellWrapper cellWrapper = new CellWrapper(cell, boundingBoxOfCell, statistic1Data, statistic2Data);
cells.add(cellWrapper);
}
}
return cells;
}
示例2: map2Areas
import dk.dma.enav.model.geometry.Area; //導入依賴的package包/類
private static Set<Area> map2Areas(List<String> areaParams){
Set<Area> areas = Sets.newHashSet();
if (areaParams != null && areaParams.size() > 0) {
areaParams.forEach(area -> {
if(area.trim().startsWith("circle")){
try{
area = URLDecoder.decode(area, "UTF-8");
System.out.println(area);
int p1 = area.indexOf("(");
int p2 = area.indexOf(")");
String[] values = area.substring(p1 + 1, p2).split(",");
Double lat = Double.valueOf(values[0].trim());
Double lon = Double.valueOf(values[1].trim());
Double radius = Double.valueOf(values[2].trim());
areas.add(new Circle(Position.create(lat, lon), radius, CoordinateSystem.CARTESIAN));
}catch(UnsupportedEncodingException e){
throw new RuntimeException(e);
}
}else{
String[] bordersAsString = area.split("\\|");
if (bordersAsString == null || bordersAsString.length != 4)
throw new IllegalArgumentException("Expected four floating point values for area argument separated by vertical bar, not: " + area);
Double lat1 = Double.valueOf(bordersAsString[0]);
Double lon1 = Double.valueOf(bordersAsString[1]);
Double lat2 = Double.valueOf(bordersAsString[2]);
Double lon2 = Double.valueOf(bordersAsString[3]);
areas.add(BoundingBox.create(Position.create(lat1, lon1), Position.create(lat2, lon2), CoordinateSystem.CARTESIAN));
}
});
}
return areas;
}
示例3: createTargetFilterPredicate
import dk.dma.enav.model.geometry.Area; //導入依賴的package包/類
/** Create a Predicate<TargetInfo> out of user supplied mmsi and area information */
static Predicate<TargetInfo> createTargetFilterPredicate(Set<Integer> mmsis, Set<Area> baseAreas, Set<Area> areas) {
Predicate<TargetInfo> mmsiPredicate = null;
if (mmsis != null && mmsis.size() > 0) {
mmsiPredicate = targetInfo -> mmsis.contains(targetInfo.getMmsi());
}
Predicate<TargetInfo> baseAreaPredicate = null;
if (baseAreas != null && baseAreas.size() > 0) {
baseAreaPredicate = targetInfo -> baseAreas.stream().anyMatch(area -> targetInfo.getPosition() != null && area.contains(targetInfo.getPosition()));
}
Predicate<TargetInfo> areaPredicate = null;
if (areas != null && areas.size() > 0) {
areaPredicate = targetInfo -> areas.stream().anyMatch(area -> targetInfo.getPosition() != null && area.contains(targetInfo.getPosition()));
}
Predicate<TargetInfo> resultingAreaPredicate = null;
if(baseAreaPredicate != null && areaPredicate == null){
resultingAreaPredicate = baseAreaPredicate;
}else if (baseAreaPredicate != null && areaPredicate != null){
resultingAreaPredicate = baseAreaPredicate.and(areaPredicate);
}else{
resultingAreaPredicate = areaPredicate;
}
if (mmsiPredicate == null && resultingAreaPredicate == null)
return t -> true;
else if (mmsiPredicate != null && resultingAreaPredicate == null)
return mmsiPredicate;
else if (mmsiPredicate == null && resultingAreaPredicate != null)
return resultingAreaPredicate;
else
return mmsiPredicate.or(resultingAreaPredicate);
}
示例4: loadCellsInArea
import dk.dma.enav.model.geometry.Area; //導入依賴的package包/類
private Set<CellWrapper> loadCellsInArea(Grid grid, Area area) {
// These are the statistics stored in the data set
Set<String> statisticNames = statisticsRepository.getStatisticNames();
// Compute the cells contained inside the area
LOG.debug("Computing which cells are in the area.");
Set<Cell> cells = grid.getCells(area);
LOG.debug("There are " + cells.size() + " cells in the area.");
// Container to collect output data
Set<CellWrapper> wrappedCells = new LinkedHashSet<>();
// Load statistic data for cells inside the area
for (Cell cell : cells) {
ArrayList<StatisticData> statisticsArray = new ArrayList<>();
for (String statisticName : statisticNames) {
StatisticData statistics = statisticsRepository.getStatisticData(statisticName, cell.getCellId());
if (statistics != null) {
statisticsArray.add(statistics);
}
}
// Add the cell to the output only if its has statistical data
if (statisticsArray.size() > 0) {
BoundingBox boundingBoxOfCell = grid.getBoundingBoxOfCell(cell);
CellWrapper wrappedCell = new CellWrapper(cell, boundingBoxOfCell, statisticsArray.toArray(new StatisticData[statisticsArray.size()]));
// Add cell to output
wrappedCells.add(wrappedCell);
}
}
LOG.debug("There are " + wrappedCells.size() + " cells with statistic data in the area");
return wrappedCells;
}
示例5: tracks
import dk.dma.enav.model.geometry.Area; //導入依賴的package包/類
/**
* Return JSON for all TargetInfo's matching sourceFilter and targetFilter.
*
* URL examples (with URL encoded filter expressions):
* - http://localhost:8080/tracks?sourceFilter=s.region%3D806
* - http://localhost:8080/tracks?sourceFilter=s.country%3DDK
* - http://localhost:8080/tracks?sourceFilter=s.country%3DDK%26s.bs%3D2190047
* - http://localhost:8080/tracks?sourceFilter=s.country%20in%20(DK%2C%20NO)
*
* - http://localhost:8080/tracks?mmsi=244820404&mmsi=345070335
*
* - http://localhost:8080/tracks?area=52.3|4.8|52.5|4.9
* - http://localhost:8080/tracks?area=52.3|4.8|52.5|4.9&area=20.0|100.0|21.0|110.0
*
* - http://localhost:8080/tracks?mmsi=244820404&mmsi=345070335&area=52.0|4.0|52.5|5.0
*
* - http://localhost:8080/tracks?mmsi=244820404&mmsi=345070335&area=52.0|4.0|52.5|5.0&area=20.0|100.0|21.0|110.0&sourceFilter=s.region%3D806|s.country%20in%20DK)
*
* @param sourceFilterExpression
* @param mmsiParams mmsi numbers to include in the result
* @param areaParams areas to include in the result
* @return
*/
@RequestMapping(value = "/tracks", produces = MediaType.APPLICATION_JSON_VALUE)
Set<TargetInfo> tracks(
@RequestParam(value="sourceFilter", required = false) String sourceFilterExpression,
@RequestParam(value="baseArea", required = false) List<String> baseAreaParams,
@RequestParam(value="area", required = false) List<String> areaParams,
@RequestParam(value="mmsi", required = false) List<String> mmsiParams){
Set<Integer> mmsis = Sets.newHashSet();
if (mmsiParams != null && mmsiParams.size() > 0) {
mmsiParams.forEach(mmsi -> mmsis.add(Integer.valueOf(mmsi)));
}
Set<Area> areas = map2Areas(areaParams);
Set<Area> baseAreas = map2Areas(baseAreaParams);
return trackService.targets(
createSourceFilterPredicate(sourceFilterExpression),
createTargetFilterPredicate(mmsis, baseAreas, areas)
);
}
示例6: getArea
import dk.dma.enav.model.geometry.Area; //導入依賴的package包/類
public Area getArea() {
return area;
}
示例7: getCellIdsWithinBoundaries
import dk.dma.enav.model.geometry.Area; //導入依賴的package包/類
@GET
@Produces(MediaType.APPLICATION_JSON)
public CellsWrapper getCellIdsWithinBoundaries(@QueryParam("north") Double north, @QueryParam("east") Double east, @QueryParam("south") Double south, @QueryParam("west") Double west) {
// http://localhost:8080/abnormal/statisticdata/cell?north=55&east=11&south=54.91&west=10.91
LOG.debug("Attempting get id's of cells inside boundary");
if (north == null) {
throw new IllegalArgumentException("Missing 'north' parameter");
}
if (east == null) {
throw new IllegalArgumentException("Missing 'east' parameter");
}
if (west == null) {
throw new IllegalArgumentException("Missing 'west' parameter");
}
if (south == null) {
throw new IllegalArgumentException("Missing 'south' parameter");
}
if (north <= south) {
throw new IllegalArgumentException("'north' parameter must be > 'south' parameter");
}
if (east <= west) {
throw new IllegalArgumentException("'east' parameter must be > 'west' parameter");
}
if (north - south > 0.1000000001) {
// throw new IllegalArgumentException("'north' and 'south' parameters must be within 0.1. The current difference is " + (north - south));
}
if (east - west > 0.1000000001) {
// throw new IllegalArgumentException("'east' and 'west' parameters must be within 0.1. The current difference is " + (east - west));
}
Double gridResolution = statisticsRepository.getMetaData().getGridResolution();
LOG.debug("Statistic set uses grid resolution of " + gridResolution);
Grid grid = Grid.create(gridResolution);
LOG.debug("Created grid with resolution " + gridResolution);
LOG.debug("Looking for cells touching area bounded by " + north + " north, " + east + " east, " + south + " south, and " + west + " west.");
Position northWest = Position.create(north, west);
Position southEast = Position.create(south, east);
Area area = BoundingBox.create(northWest, southEast, CoordinateSystem.CARTESIAN);
return new CellsWrapper(loadCellsInArea(grid, area));
}