本文整理汇总了Java中dk.dma.enav.model.geometry.Position类的典型用法代码示例。如果您正苦于以下问题:Java Position类的具体用法?Java Position怎么用?Java Position使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Position类属于dk.dma.enav.model.geometry包,在下文中一共展示了Position类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testTargetsFilteredByTargetInfo
import dk.dma.enav.model.geometry.Position; //导入依赖的package包/类
/** Test all targets can be filtered and extracted from tracker by TargetInfo */
@Test
public void testTargetsFilteredByTargetInfo() throws Exception {
BoundingBox boundingBox = BoundingBox.create(
Position.create(55.0, 11.0),
Position.create(56.0, 12.0),
CoordinateSystem.CARTESIAN
);
assertEquals(22, aisTrackService.targets(
src -> true,
target -> {
final boolean test = boundingBox.contains(target.getPosition());
System.out.println("Testing if " + target.getPosition() + " lies within " + boundingBox + ": " + (test ? "OK":"NOK"));
return test;
})
.size()
);
}
开发者ID:dma-ais,项目名称:AisTrack,代码行数:20,代码来源:AisTrackServiceTest.java
示例2: testCreateTargetFilterPredicate_baseAreaOnly
import dk.dma.enav.model.geometry.Position; //导入依赖的package包/类
@Test
public void testCreateTargetFilterPredicate_baseAreaOnly() throws Exception {
Predicate<TargetInfo> predicate = TrackResource.createTargetFilterPredicate(
null,
Sets.newHashSet(
BoundingBox.create(Position.create(55.0, 10.0), Position.create(56.2, 12), CoordinateSystem.CARTESIAN)
),
null
);
// Test a target not matching any mmsi or area
TargetInfo targetInfo = Mockito.mock(TargetInfo.class);
when(targetInfo.getPosition()).thenReturn(Position.create(54.9, 9.9));
assertFalse(predicate.test(targetInfo));
// Test a target matching an mmsi but not an area
targetInfo = Mockito.mock(TargetInfo.class);
when(targetInfo.getPosition()).thenReturn(Position.create(55.9, 10.9));
assertTrue(predicate.test(targetInfo));
}
开发者ID:dma-ais,项目名称:AisTrack,代码行数:21,代码来源:TrackResourceTest.java
示例3: findBoundingBox
import dk.dma.enav.model.geometry.Position; //导入依赖的package包/类
private static BoundingBox findBoundingBox(UriInfo info) {
String box = QueryParameterValidators.getParameter(info, "box", null);
if (box != null) {
String[] str = box.split(",");
if (str.length != 4) {
throw new UnsupportedOperationException(
"A box must contain exactly 4 points, was "
+ str.length + "(" + box + ")");
}
double lat1 = Double.parseDouble(str[0]);
double lon1 = Double.parseDouble(str[1]);
double lat2 = Double.parseDouble(str[2]);
double lon2 = Double.parseDouble(str[3]);
Position p1 = Position.create(lat1, lon1);
Position p2 = Position.create(lat2, lon2);
return BoundingBox.create(p1, p2, CoordinateSystem.CARTESIAN);
}
return null;
}
开发者ID:dma-ais,项目名称:AisView,代码行数:20,代码来源:QueryParameterHelper.java
示例4: filterOnBoundingBox
import dk.dma.enav.model.geometry.Position; //导入依赖的package包/类
/**
* TargetInfo predicate for boundingbox filtering
*
* @param bbox
* @return
*/
public static Predicate<TargetInfo> filterOnBoundingBox(final BoundingBox bbox) {
return new Predicate<TargetInfo>() {
@Override
public boolean test(TargetInfo arg0) {
if (arg0.hasPositionInfo()) {
Position p = arg0.getPosition();
if (p != null
&& Position.isValid(p.getLatitude(),
p.getLongitude())) {
return bbox.contains(p);
}
}
return false;
}
};
}
开发者ID:dma-ais,项目名称:AisView,代码行数:24,代码来源:TargetInfoFilters.java
示例5: testDoNotCountTracksWithSogLessThanTwo
import dk.dma.enav.model.geometry.Position; //导入依赖的package包/类
@Test
public void testDoNotCountTracksWithSogLessThanTwo() {
track.update(System.currentTimeMillis(), Position.create(56, 12), 0.0f, 1.99f, 1.99f);
Long oldCellId = null;
CellChangedEvent event = new CellChangedEvent(track, oldCellId);
context.checking(new Expectations() {{
oneOf(trackingService).registerSubscriber(statistic);
ignoring(statisticsService).incStatisticStatistics(with(STATISTIC_NAME), with(any(String.class)));
never(statisticsRepository).getStatisticData(with(STATISTIC_NAME), with(any(Long.class)));
never(statisticsRepository).putStatisticData(with(STATISTIC_NAME), (Long) with(any(Long.class)), with(any(StatisticData.class)));
}});
statistic.start();
statistic.onCellIdChanged(event);
// Assert expectations and captured values
context.assertIsSatisfied();
}
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:21,代码来源:ShipTypeAndSizeStatisticTest.java
示例6: testCountTracksWithSogOverTwo
import dk.dma.enav.model.geometry.Position; //导入依赖的package包/类
@Test
public void testCountTracksWithSogOverTwo() {
track.update(System.currentTimeMillis(), Position.create(56, 12), 0.0f, 2.01f, 2.01f);
Long oldCellId = null;
CellChangedEvent event = new CellChangedEvent(track, oldCellId);
context.checking(new Expectations() {{
oneOf(trackingService).registerSubscriber(statistic);
ignoring(statisticsService).incStatisticStatistics(with(STATISTIC_NAME), with(any(String.class)));
oneOf(statisticsRepository).getStatisticData(with(STATISTIC_NAME), with(any(Long.class)));
oneOf(statisticsRepository).putStatisticData(with(STATISTIC_NAME), (Long) with(any(Long.class)), with(any(StatisticData.class)));
}});
statistic.start();
statistic.onCellIdChanged(event);
// Assert expectations and captured values
context.assertIsSatisfied();
}
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:21,代码来源:ShipTypeAndSizeStatisticTest.java
示例7: centerOfVessel
import dk.dma.enav.model.geometry.Position; //导入依赖的package包/类
/**
* Given an AIS position, the vessel's heading and dimensions from position sensor to bow, stern, starboard, and port
* compute the vessel's center point.
*
* @param aisPosition
* @param hdg
* @param dimStern
* @param dimBow
* @param dimPort
* @param dimStarboard
* @return
*/
static Position centerOfVessel(Position aisPosition, float hdg, int dimStern, int dimBow, int dimPort, int dimStarboard) {
// Compute direction of half axis alpha
final double thetaDeg = compass2cartesian(hdg);
// Transform latitude/longitude to cartesian coordinates
final Position geodeticReference = aisPosition;
final CoordinateConverter coordinateConverter = new CoordinateConverter(geodeticReference.getLongitude(), geodeticReference.getLatitude());
final double trackLatitude = aisPosition.getLatitude();
final double trackLongitude = aisPosition.getLongitude();
final double x = coordinateConverter.lon2x(trackLongitude, trackLatitude);
final double y = coordinateConverter.lat2y(trackLongitude, trackLatitude);
// Cartesion point of AIS position
final Point pAis = new Point(x, y);
// Compute cartesian center of vessel
final Point pc = new Point((dimBow + dimStern)/2 - dimStern, (dimPort+dimStarboard)/2 - dimStarboard);
// Rotate to comply with hdg
final Point pcr = pc.rotate(pAis, thetaDeg);
// Convert back to geodesic coordinates
return Position.create(coordinateConverter.y2Lat(pcr.getX(), pcr.getY()), coordinateConverter.x2Lon(pcr.getX(), pcr.getY()));
}
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:37,代码来源:FreeFlowAnalysis.java
示例8: testIsDriftDistanceLongEnough
import dk.dma.enav.model.geometry.Position; //导入依赖的package包/类
@Test
public void testIsDriftDistanceLongEnough() {
final long t0 = System.currentTimeMillis();
final long dt = 7000;
// nonDriftingTrack (speed normal, cog/hdg deviation normal)
Track track = new Track(219000001);
track.update(t0, Position.create(56.0, 12.0), 45.0f, 12.0f, 45.1f);
assertFalse(driftAnalysis.isDriftDistanceLongEnough(track));
track.update(t0+dt, Position.create(56.0001, 12.0001), 45.0f, 12.0f, 45.1f);
assertFalse(driftAnalysis.isDriftDistanceLongEnough(track));
// driftingTrack
track = new Track(219000001);
track.update(t0, Position.create(56.0000, 11.0000), -45.0f, (float) (driftAnalysis.SPEED_LOW_MARK + 0.5), 45.1f);
assertFalse(driftAnalysis.isDriftDistanceLongEnough(track));
track.update(t0+dt, Position.create(56.0001, 11.0001), -45.0f, (float) (driftAnalysis.SPEED_LOW_MARK + 0.5), 45.1f); // 12 m - http://www.csgnetwork.com/gpsdistcalc.html
assertFalse(driftAnalysis.isDriftDistanceLongEnough(track));
track.update(t0+2*dt, Position.create(56.0010, 11.0010), -45.0f, (float) (driftAnalysis.SPEED_LOW_MARK + 0.5), 45.1f); // 155 m
assertFalse(driftAnalysis.isDriftDistanceLongEnough(track));
track.update(t0+3*dt, Position.create(56.0100, 11.0100), -45.0f, (float) (driftAnalysis.SPEED_LOW_MARK + 0.5), 45.1f); // 1273 m
assertTrue(driftAnalysis.isDriftDistanceLongEnough(track));
}
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:24,代码来源:DriftAnalysisTest.java
示例9: noEventIsRaisedForSlowSpeedChange
import dk.dma.enav.model.geometry.Position; //导入依赖的package包/类
@Test
public void noEventIsRaisedForSlowSpeedChange() {
// Perform test - none of the required data are there
context.checking(new Expectations() {{
never(eventRepository).findOngoingEventByVessel(219000606, SuddenSpeedChangeEvent.class);
never(eventRepository).save(with(any(Event.class)));
}});
analysis.start();
int deltaSecs = 61;
PositionChangedEvent event = new PositionChangedEvent(track, null);
track.update(track.getTimeOfLastPositionReport() + deltaSecs * 1000, Position.create(56, 12), 45.0f, 12.2f, 45.0f);
analysis.onSpeedOverGroundUpdated(event);
track.update(track.getTimeOfLastPositionReport() + deltaSecs * 1000, Position.create(56, 12), 45.0f, 0.1f, 45.0f);
analysis.onSpeedOverGroundUpdated(event);
context.assertIsSatisfied();
}
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:21,代码来源:SuddenSpeedChangeAnalysisTest.java
示例10: noEventIsRaisedForFastSpeedChangeAboveEightKnots
import dk.dma.enav.model.geometry.Position; //导入依赖的package包/类
@Test
public void noEventIsRaisedForFastSpeedChangeAboveEightKnots() {
// Perform test - none of the required data are there
context.checking(new Expectations() {{
never(eventRepository).save(with(any(Event.class)));
}});
analysis.start();
int deltaSecs = 7;
PositionChangedEvent event = new PositionChangedEvent(track, null);
track.update(track.getTimeOfLastPositionReport() + (deltaSecs + 0) * 1000, Position.create(56, 12), 45.0f, 22.2f, 45.0f);
analysis.onSpeedOverGroundUpdated(event);
track.update(track.getTimeOfLastPositionReport() + (deltaSecs + 1) * 1000, Position.create(56, 12), 45.0f, 9.0f, 45.0f);
analysis.onSpeedOverGroundUpdated(event);
context.assertIsSatisfied();
}
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:20,代码来源:SuddenSpeedChangeAnalysisTest.java
示例11: noEventIsRaisedWhenTrackHasBeenStale
import dk.dma.enav.model.geometry.Position; //导入依赖的package包/类
@Test
public void noEventIsRaisedWhenTrackHasBeenStale() {
// Perform test - none of the required data are there
context.checking(new Expectations() {{
never(eventRepository).save(with(any(Event.class)));
}});
analysis.start();
int deltaSecs = 7;
PositionChangedEvent event = new PositionChangedEvent(track, null);
track.update(track.getTimeOfLastPositionReport() + (deltaSecs + 0) * 1000, Position.create(56, 12), 45.0f, 12.2f, 45.0f);
analysis.onSpeedOverGroundUpdated(event);
track.update(track.getTimeOfLastPositionReport() + (deltaSecs + 1) * 1000, Position.create(56, 12), 45.0f, 0.1f, 45.0f);
analysis.onSpeedOverGroundUpdated(event);
TrackStaleEvent staleEvent = new TrackStaleEvent(track);
analysis.onTrackStale(staleEvent);
track.update(track.getTimeOfLastPositionReport() + (deltaSecs + 24*60*60) * 1000, Position.create(56, 12), 45.0f, 0.1f, 45.0f);
analysis.onSpeedOverGroundUpdated(event);
context.assertIsSatisfied();
}
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:25,代码来源:SuddenSpeedChangeAnalysisTest.java
示例12: noEventIsRaisedWhenSpeedIsUndefined
import dk.dma.enav.model.geometry.Position; //导入依赖的package包/类
@Test
public void noEventIsRaisedWhenSpeedIsUndefined() {
// Perform test - none of the required data are there
context.checking(new Expectations() {{
never(eventRepository).save(with(any(Event.class)));
}});
analysis.start();
int deltaSecs = 7;
PositionChangedEvent event = new PositionChangedEvent(track, null);
track.update(track.getTimeOfLastPositionReport() + (deltaSecs + 0) * 1000, Position.create(56, 12), 45.0f, 102.3f /* 1023 int */, 45.0f);
analysis.onSpeedOverGroundUpdated(event);
track.update(track.getTimeOfLastPositionReport() + (deltaSecs + 1) * 1000, Position.create(56, 12), 45.0f, 0.1f, 45.0f);
analysis.onSpeedOverGroundUpdated(event);
for (int t=0; t < analysis.SPEED_SUSTAIN_SECS*2; t += 10) {
track.update(track.getTimeOfLastPositionReport() + (deltaSecs + 2) * 1000 + t, Position.create(56, 12), 45.0f, 0.1f, 45.0f);
analysis.onSpeedOverGroundUpdated(event);
}
context.assertIsSatisfied();
}
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:25,代码来源:SuddenSpeedChangeAnalysisTest.java
示例13: loadDummyCells
import dk.dma.enav.model.geometry.Position; //导入依赖的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;
}
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:34,代码来源:CellResource.java
示例14: getVesselList
import dk.dma.enav.model.geometry.Position; //导入依赖的package包/类
public synchronized BaseVesselList getVesselList(BaseVesselList list, VesselListFilter filter, Position pointA, Position pointB) {
// Iterate through all vessel targets and add to response
int inWorld = 0;
for (AisTargetEntry targetEntry : targetsMap.values()) {
AisVesselTarget vesselTarget = getFilteredAisVessel(targetEntry, filter);
if (vesselTarget == null || vesselTarget.getVesselPosition() == null
|| vesselTarget.getVesselPosition().getPos() == null)
continue;
inWorld++;
// Is it inside the requested area
if (rejectedByPosition(vesselTarget, pointA, pointB)) {
continue;
}
list.addTarget(vesselTarget, targetEntry.getAnonId());
}
list.setInWorldCount(inWorld);
return list;
}
开发者ID:dma-ais,项目名称:AisAnalysis,代码行数:24,代码来源:AisViewHandler.java
示例15: getGeoLocation
import dk.dma.enav.model.geometry.Position; //导入依赖的package包/类
/**
* Get position as {@link Position} object
*
* @return
*/
public Position getGeoLocation() {
double lat = getLatitude() / resolution / 60.0;
double lon = getLongitude() / resolution / 60.0;
if (Position.isValid(lat, lon)) {
return Position.create(lat, lon);
}
return null;
}
开发者ID:videgro,项目名称:Ships,代码行数:14,代码来源:AisPosition.java
示例16: AisVesselInfo
import dk.dma.enav.model.geometry.Position; //导入依赖的package包/类
public AisVesselInfo(AisPositionMessage vessel){
msgType=MsgType.Position.name();
received=System.currentTimeMillis();
userId=vessel.getUserId();
utcSec=vessel.getUtcSec();
position=vessel.getValidPosition();
navStatus=vessel.getNavStatus();
rot=vessel.getRot();
sog=vessel.getSog();
cog=vessel.getCog();
trueHeading=vessel.getTrueHeading();
}
开发者ID:SignalK,项目名称:signalk-core-java,代码行数:13,代码来源:AisVesselInfo.java
示例17: map2Areas
import dk.dma.enav.model.geometry.Position; //导入依赖的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;
}
开发者ID:dma-ais,项目名称:AisTrack,代码行数:33,代码来源:TrackResource.java
示例18: serialize
import dk.dma.enav.model.geometry.Position; //导入依赖的package包/类
@Override
public void serialize(Position pos, com.fasterxml.jackson.core.JsonGenerator jg, com.fasterxml.jackson.databind.SerializerProvider serializerProvider) throws IOException, com.fasterxml.jackson.core.JsonProcessingException {
jg.writeStartObject();
jg.writeNumberField("lat", (float) pos.getLatitude());
jg.writeNumberField("lon", (float) pos.getLongitude());
jg.writeEndObject();
}
开发者ID:dma-ais,项目名称:AisTrack,代码行数:8,代码来源:PositionSerializer.java
示例19: CustomJacksonMapper
import dk.dma.enav.model.geometry.Position; //导入依赖的package包/类
public CustomJacksonMapper() {
setSerializationInclusion(JsonInclude.Include.NON_NULL);
SimpleModule module = new SimpleModule();
module.addSerializer(AisPacketSource.class, new AisPacketSourceSerializer());
module.addSerializer(Country.class, new CountrySerializer());
module.addSerializer(Position.class, new PositionSerializer());
module.addSerializer(Date.class, new DateSerializer());
module.addSerializer(TargetInfo.class, new TargetInfoSerializer());
this.registerModule(module);
}
开发者ID:dma-ais,项目名称:AisTrack,代码行数:12,代码来源:CustomJacksonMapper.java
示例20: testCreateTargetFilterPredicate_mmsiAndBaseAreaOnly
import dk.dma.enav.model.geometry.Position; //导入依赖的package包/类
@Test
public void testCreateTargetFilterPredicate_mmsiAndBaseAreaOnly() throws Exception {
Predicate<TargetInfo> predicate = TrackResource.createTargetFilterPredicate(
Sets.newHashSet(219000000, 219000001, 219000002),
Sets.newHashSet(
BoundingBox.create(Position.create(55.0, 10.0), Position.create(56.2, 12), CoordinateSystem.CARTESIAN)
),
null
);
// Test a target not matching any mmsi or baseArea
TargetInfo targetInfo = Mockito.mock(TargetInfo.class);
when(targetInfo.getMmsi()).thenReturn(123123123);
when(targetInfo.getPosition()).thenReturn(Position.create(54.9, 9.9));
assertFalse(predicate.test(targetInfo));
// Test a target matching a baseArea but not mmsi
targetInfo = Mockito.mock(TargetInfo.class);
when(targetInfo.getMmsi()).thenReturn(123123123);
when(targetInfo.getPosition()).thenReturn(Position.create(55.9, 10.9));
assertTrue(predicate.test(targetInfo));
// Test a target matching an mmsi but not a baseArea
targetInfo = Mockito.mock(TargetInfo.class);
when(targetInfo.getMmsi()).thenReturn(219000001);
when(targetInfo.getPosition()).thenReturn(Position.create(54.9, 9.9));
assertTrue(predicate.test(targetInfo));
// Test a target matching both mmsi and baseArea
targetInfo = Mockito.mock(TargetInfo.class);
when(targetInfo.getMmsi()).thenReturn(219000001);
when(targetInfo.getPosition()).thenReturn(Position.create(55.9, 10.9));
assertTrue(predicate.test(targetInfo));
}
开发者ID:dma-ais,项目名称:AisTrack,代码行数:35,代码来源:TrackResourceTest.java
注:本文中的dk.dma.enav.model.geometry.Position类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论