use of net.opengis.gml._3.ObjectFactory in project RouteConverter by cpesch.
the class Gpx10Format method createWayPoints.
private List<Gpx.Wpt> createWayPoints(GpxRoute route, int startIndex, int endIndex) {
ObjectFactory objectFactory = new ObjectFactory();
List<Gpx.Wpt> wpts = new ArrayList<>();
List<GpxPosition> positions = route.getPositions();
for (int i = startIndex; i < endIndex; i++) {
GpxPosition position = positions.get(i);
BigDecimal latitude = formatPosition(position.getLatitude());
BigDecimal longitude = formatPosition(position.getLongitude());
if (latitude == null || longitude == null)
continue;
Gpx.Wpt wpt = position.getOrigin(Gpx.Wpt.class);
if (wpt == null || !reuseReadObjectsForWriting)
wpt = objectFactory.createGpxWpt();
wpt.setLat(latitude);
wpt.setLon(longitude);
wpt.setTime(isWriteTime() ? formatXMLTime(position.getTime()) : null);
wpt.setEle(isWriteElevation() ? formatElevation(position.getElevation()) : null);
wpt.setCourse(isWriteHeading() ? formatHeading(position.getHeading()) : null);
wpt.setSpeed(isWriteSpeed() && position.getSpeed() != null ? formatSpeed(kmhToMs(position.getSpeed())) : null);
if (isWriteSpeed() && reuseReadObjectsForWriting)
wpt.setCmt(formatSpeedDescription(wpt.getCmt(), position.getSpeed()));
if (isWriteHeading() && reuseReadObjectsForWriting)
wpt.setCmt(addHeading(wpt.getCmt(), position.getHeading()));
wpt.setName(isWriteName() ? splitNameAndDesc ? asName(position.getDescription()) : trim(position.getDescription()) : null);
wpt.setDesc(isWriteName() && splitNameAndDesc ? asDesc(position.getDescription(), wpt.getDesc()) : null);
wpt.setHdop(isWriteAccuracy() && position.getHdop() != null ? formatAccuracy(position.getHdop()) : null);
wpt.setPdop(isWriteAccuracy() && position.getPdop() != null ? formatAccuracy(position.getPdop()) : null);
wpt.setVdop(isWriteAccuracy() && position.getVdop() != null ? formatAccuracy(position.getVdop()) : null);
wpt.setSat(isWriteAccuracy() && position.getSatellites() != null ? formatInt(position.getSatellites()) : null);
wpts.add(wpt);
}
return wpts;
}
use of net.opengis.gml._3.ObjectFactory in project RouteConverter by cpesch.
the class Gpx10Format method createGpx.
private Gpx createGpx(List<GpxRoute> routes) {
ObjectFactory objectFactory = new ObjectFactory();
Gpx gpx = null;
for (GpxRoute route : routes) {
gpx = recycleGpx(route);
if (gpx != null)
break;
}
if (gpx == null || !reuseReadObjectsForWriting)
gpx = objectFactory.createGpx();
gpx.setCreator(getCreator());
gpx.setVersion(VERSION);
if (isWriteMetaData())
gpx.setTime(formatXMLTime(now()));
for (GpxRoute route : routes) {
switch(route.getCharacteristics()) {
case Waypoints:
createMetaData(route, gpx);
gpx.getWpt().addAll(createWayPoints(route, 0, route.getPositionCount()));
break;
case Route:
gpx.getRte().addAll(createRoute(route, 0, route.getPositionCount()));
break;
case Track:
gpx.getTrk().addAll(createTrack(route, 0, route.getPositionCount()));
break;
default:
throw new IllegalArgumentException("Unknown RouteCharacteristics " + route.getCharacteristics());
}
}
return gpx;
}
use of net.opengis.gml._3.ObjectFactory in project RouteConverter by cpesch.
the class GoPal3RouteFormat method createGoPal.
private Tour createGoPal(GoPalRoute route, int startIndex, int endIndex) {
ObjectFactory objectFactory = new ObjectFactory();
Tour tour = objectFactory.createTour();
tour.setOptions(createOptions(route));
for (int i = startIndex; i < endIndex; i++) {
GoPalPosition position = route.getPosition(i);
Tour.Dest dest = objectFactory.createTourDest();
if (position.getX() != null)
dest.setLongitude(position.getX());
if (position.getY() != null)
dest.setLatitude(position.getY());
dest.setCity(position.getCity());
if (position.getCountry() != null)
dest.setCountry(position.getCountry());
if (position.getHouseNumber() != null)
dest.setHouse(position.getHouseNumber());
dest.setStreet(position.getStreet());
dest.setZip(position.getZipCode());
if (i == startIndex)
dest.setStartPos((short) 1);
tour.getDest().add(dest);
}
return tour;
}
use of net.opengis.gml._3.ObjectFactory in project RouteConverter by cpesch.
the class GoPal5RouteFormat method createGoPal.
private Tour createGoPal(GoPalRoute route, int startIndex, int endIndex) {
ObjectFactory objectFactory = new ObjectFactory();
Tour tour = objectFactory.createTour();
tour.setRouteOptions(createRouteOptions(route));
for (int i = startIndex; i < endIndex; i++) {
GoPalPosition position = route.getPosition(i);
if (i == startIndex) {
tour.setStart(createStart(position));
} else {
tour.getDestination().add(createDestination(position));
}
}
return tour;
}
use of net.opengis.gml._3.ObjectFactory in project RouteConverter by cpesch.
the class GoPal5RouteFormat method createDestination.
private Tour.Destination createDestination(GoPalPosition position) {
ObjectFactory objectFactory = new ObjectFactory();
Tour.Destination destination = objectFactory.createTourDestination();
Tour.Destination.Coordinates coordinates = objectFactory.createTourDestinationCoordinates();
if (position.getX() != null)
coordinates.setMercatorx(position.getX());
if (position.getY() != null)
coordinates.setMercatory(position.getY());
if (position.getLongitude() != null)
coordinates.setLongitude(formatPosition(position.getLongitude()));
if (position.getLatitude() != null)
coordinates.setLatitude(formatPosition(position.getLatitude()));
destination.setCoordinates(coordinates);
Tour.Destination.City city = objectFactory.createTourDestinationCity();
city.setName(position.getCity());
city.setSuburb(position.getSuburb());
destination.setCity(city);
Tour.Destination.Country country = objectFactory.createTourDestinationCountry();
if (position.getCountry() != null)
country.setCode(position.getCountry());
destination.setCountry(country);
Tour.Destination.State state = objectFactory.createTourDestinationState();
if (position.getState() != null)
state.setName(position.getState());
destination.setState(state);
Tour.Destination.HouseNumber houseNumber = objectFactory.createTourDestinationHouseNumber();
if (position.getHouseNumber() != null) {
houseNumber.setValue(position.getHouseNumber());
houseNumber.setType("middle_of_street");
}
destination.setHouseNumber(houseNumber);
Tour.Destination.Street street = objectFactory.createTourDestinationStreet();
street.setName(position.getStreet());
if (position.getHouseNumber() != null)
street.setHouseNumberAvailable("no");
destination.setStreet(street);
Tour.Destination.SideStreet sideStreet = objectFactory.createTourDestinationSideStreet();
sideStreet.setName(position.getSideStreet());
destination.setSideStreet(sideStreet);
Tour.Destination.Zip zip = objectFactory.createTourDestinationZip();
zip.setCode(position.getZipCode());
destination.setZip(zip);
return destination;
}
Aggregations