Search in sources :

Example 51 with ObjectFactory

use of com.helger.xsds.peppol.smp1.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;
}
Also used : ObjectFactory(slash.navigation.gopal.binding5.ObjectFactory) Tour(slash.navigation.gopal.binding5.Tour)

Example 52 with ObjectFactory

use of com.helger.xsds.peppol.smp1.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;
}
Also used : ObjectFactory(slash.navigation.gopal.binding5.ObjectFactory) Tour(slash.navigation.gopal.binding5.Tour)

Example 53 with ObjectFactory

use of com.helger.xsds.peppol.smp1.ObjectFactory in project RouteConverter by cpesch.

the class GoPal7RouteFormat method createRouteOptions.

private Tour.RouteOptions createRouteOptions(GoPalRoute route) {
    Tour.RouteOptions options = route.getOptions(Tour.RouteOptions.class);
    if (options == null) {
        ObjectFactory objectFactory = new ObjectFactory();
        options = objectFactory.createTourRouteOptions();
        Tour.RouteOptions.NaviMode naviMode = objectFactory.createTourRouteOptionsNaviMode();
        // bicycle, car, motorbike, pedestrian
        naviMode.setValue(preferences.get(VERSION_PREFIX + "naviMode", "motorbike"));
        options.setNaviMode(naviMode);
        Tour.RouteOptions.OptimizationMode optimizationMode = objectFactory.createTourRouteOptionsOptimizationMode();
        // fast, short
        optimizationMode.setValue(preferences.get(VERSION_PREFIX + "optimizationMode", "short"));
        options.setOptimizationMode(optimizationMode);
        Tour.RouteOptions.TTIBypass bypass = objectFactory.createTourRouteOptionsTTIBypass();
        // automatic, disabled, manual
        bypass.setCalculation(preferences.get(VERSION_PREFIX + "ttiBypass", "automatic"));
        bypass.setMode("avoid");
        options.setTTIBypass(bypass);
        Tour.RouteOptions.RoadUsageTypes usageTypes = objectFactory.createTourRouteOptionsRoadUsageTypes();
        Tour.RouteOptions.RoadUsageTypes.CarTrains carTrains = objectFactory.createTourRouteOptionsRoadUsageTypesCarTrains();
        // avoid, use, prohibit
        carTrains.setMode(preferences.get(VERSION_PREFIX + "carTrains", "use"));
        usageTypes.setCarTrains(carTrains);
        Tour.RouteOptions.RoadUsageTypes.Ferries ferries = objectFactory.createTourRouteOptionsRoadUsageTypesFerries();
        // avoid, use, prohibit
        ferries.setMode(preferences.get(VERSION_PREFIX + "ferries", "avoid"));
        usageTypes.setFerries(ferries);
        Tour.RouteOptions.RoadUsageTypes.IPDRoads ipdRoads = objectFactory.createTourRouteOptionsRoadUsageTypesIPDRoads();
        // avoid, use, prohibit
        ipdRoads.setMode(preferences.get(VERSION_PREFIX + "ipdRoads", "use"));
        usageTypes.setIPDRoads(ipdRoads);
        Tour.RouteOptions.RoadUsageTypes.MotorWays motorWays = objectFactory.createTourRouteOptionsRoadUsageTypesMotorWays();
        // avoid, use, prohibit
        motorWays.setMode(preferences.get(VERSION_PREFIX + "motorWays", "avoid"));
        usageTypes.setMotorWays(motorWays);
        Tour.RouteOptions.RoadUsageTypes.SeasonalRestrictedRoads seasonalRestrictedRoads = objectFactory.createTourRouteOptionsRoadUsageTypesSeasonalRestrictedRoads();
        // avoid, use, prohibit
        seasonalRestrictedRoads.setMode(preferences.get(VERSION_PREFIX + "seasonalRestrictedRoads", "use"));
        usageTypes.setSeasonalRestrictedRoads(seasonalRestrictedRoads);
        Tour.RouteOptions.RoadUsageTypes.SpecialChargeRoads specialChargeRoads = objectFactory.createTourRouteOptionsRoadUsageTypesSpecialChargeRoads();
        // avoid, use, prohibit
        specialChargeRoads.setMode(preferences.get(VERSION_PREFIX + "specialChargeRoads", "avoid"));
        usageTypes.setSpecialChargeRoads(specialChargeRoads);
        Tour.RouteOptions.RoadUsageTypes.TimeRestrictedRoads timeRestrictedRoads = objectFactory.createTourRouteOptionsRoadUsageTypesTimeRestrictedRoads();
        // avoid, use, prohibit
        timeRestrictedRoads.setMode(preferences.get(VERSION_PREFIX + "timeRestrictedRoads", "use"));
        usageTypes.setTimeRestrictedRoads(timeRestrictedRoads);
        Tour.RouteOptions.RoadUsageTypes.TollRoads tollRoads = objectFactory.createTourRouteOptionsRoadUsageTypesTollRoads();
        // avoid, use, prohibit
        tollRoads.setMode(preferences.get(VERSION_PREFIX + "tollRoads", "avoid"));
        usageTypes.setTollRoads(tollRoads);
        Tour.RouteOptions.RoadUsageTypes.TrafficFlowInfo trafficFlowInfo = objectFactory.createTourRouteOptionsRoadUsageTypesTrafficFlowInfo();
        // avoid, use, prohibit
        trafficFlowInfo.setMode(preferences.get(VERSION_PREFIX + "trafficFlowInfo", "use"));
        usageTypes.setTrafficFlowInfo(trafficFlowInfo);
        Tour.RouteOptions.RoadUsageTypes.Tunnels tunnels = objectFactory.createTourRouteOptionsRoadUsageTypesTunnels();
        // avoid, use, prohibit
        tunnels.setMode(preferences.get(VERSION_PREFIX + "tunnels", "use"));
        usageTypes.setTunnels(tunnels);
        Tour.RouteOptions.RoadUsageTypes.UnpavedRoads unpavedRoads = objectFactory.createTourRouteOptionsRoadUsageTypesUnpavedRoads();
        // avoid, use, prohibit
        unpavedRoads.setMode(preferences.get(VERSION_PREFIX + "unpavedRoads", "avoid"));
        usageTypes.setUnpavedRoads(unpavedRoads);
        options.setRoadUsageTypes(usageTypes);
        Tour.RouteOptions.TravelSpeeds travelSpeeds = objectFactory.createTourRouteOptionsTravelSpeeds();
        Tour.RouteOptions.TravelSpeeds.Bicycle bicycle = objectFactory.createTourRouteOptionsTravelSpeedsBicycle();
        // Km/h
        bicycle.setSpeed(formatSpeed(preferences.getDouble(VERSION_PREFIX + "bicycleSpeed", 14.4)));
        bicycle.setUnit(ROUTE_OPTIONS_SPEED_UNIT);
        travelSpeeds.setBicycle(bicycle);
        Tour.RouteOptions.TravelSpeeds.Pedestrian pedestrian = objectFactory.createTourRouteOptionsTravelSpeedsPedestrian();
        // Km/h
        pedestrian.setSpeed(formatSpeed(preferences.getDouble(VERSION_PREFIX + "pedestrianSpeed", 3.6)));
        pedestrian.setUnit(ROUTE_OPTIONS_SPEED_UNIT);
        travelSpeeds.setPedestrian(pedestrian);
        Tour.RouteOptions.TravelSpeeds.Vehicle vehicle = objectFactory.createTourRouteOptionsTravelSpeedsVehicle();
        // Km/h
        vehicle.setSpeed(formatSpeed(preferences.getDouble(VERSION_PREFIX + "vehicleSpeed", 80.0)));
        vehicle.setUnit(ROUTE_OPTIONS_SPEED_UNIT);
        Tour.RouteOptions.TravelSpeeds.Vehicle.MotorWay motorWay = objectFactory.createTourRouteOptionsTravelSpeedsVehicleMotorWay();
        // Km/h
        motorWay.setSpeed(formatSpeed(preferences.getDouble(VERSION_PREFIX + "vehicleSpeedMotorWay", 120.0)));
        motorWay.setUnit(ROUTE_OPTIONS_SPEED_UNIT);
        vehicle.setMotorWay(motorWay);
        Tour.RouteOptions.TravelSpeeds.Vehicle.PedestrianArea pedestrianArea = objectFactory.createTourRouteOptionsTravelSpeedsVehiclePedestrianArea();
        // Km/h
        pedestrianArea.setSpeed(formatSpeed(preferences.getDouble(VERSION_PREFIX + "vehicleSpeedPedestrianArea", 7.2)));
        pedestrianArea.setUnit(ROUTE_OPTIONS_SPEED_UNIT);
        vehicle.setPedestrianArea(pedestrianArea);
        travelSpeeds.setVehicle(vehicle);
        options.setTravelSpeeds(travelSpeeds);
    }
    return options;
}
Also used : ObjectFactory(slash.navigation.gopal.binding5.ObjectFactory) Tour(slash.navigation.gopal.binding5.Tour)

Example 54 with ObjectFactory

use of com.helger.xsds.peppol.smp1.ObjectFactory in project RouteConverter by cpesch.

the class GoPal7RouteFormat method createStart.

private Tour.Start createStart(GoPalPosition position) {
    ObjectFactory objectFactory = new ObjectFactory();
    Tour.Start start = objectFactory.createTourStart();
    Tour.Start.Coordinates coordinates = objectFactory.createTourStartCoordinates();
    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()));
    start.setCoordinates(coordinates);
    Tour.Start.City city = objectFactory.createTourStartCity();
    city.setName(position.getCity());
    city.setSuburb(position.getSuburb());
    start.setCity(city);
    Tour.Start.Country country = objectFactory.createTourStartCountry();
    country.setCode(formatCountry(position));
    start.setCountry(country);
    Tour.Start.State state = objectFactory.createTourStartState();
    if (position.getState() != null)
        state.setName(position.getState());
    start.setState(state);
    Tour.Start.HouseNumber houseNumber = objectFactory.createTourStartHouseNumber();
    if (position.getHouseNumber() != null) {
        houseNumber.setValue(position.getHouseNumber());
        houseNumber.setType("middle_of_street");
    }
    start.setHouseNumber(houseNumber);
    Tour.Start.Street street = objectFactory.createTourStartStreet();
    street.setName(position.getStreet());
    if (position.getHouseNumber() != null)
        street.setHouseNumberAvailable("no");
    start.setStreet(street);
    Tour.Start.SideStreet sideStreet = objectFactory.createTourStartSideStreet();
    sideStreet.setName(position.getSideStreet());
    start.setSideStreet(sideStreet);
    Tour.Start.Zip zip = objectFactory.createTourStartZip();
    zip.setCode(position.getZipCode());
    start.setZip(zip);
    return start;
}
Also used : ObjectFactory(slash.navigation.gopal.binding5.ObjectFactory) Tour(slash.navigation.gopal.binding5.Tour)

Example 55 with ObjectFactory

use of com.helger.xsds.peppol.smp1.ObjectFactory in project peppol-commons by phax.

the class SMPExtensionConverterTest method testConvertFromExtensionType.

@Test
public void testConvertFromExtensionType() {
    // Try converting an empty extension
    assertNull(SMPExtensionConverter.convertToString((ExtensionType) null));
    assertNull(SMPExtensionConverter.convertToString(new ObjectFactory().createExtensionType()));
}
Also used : ObjectFactory(com.helger.xsds.peppol.smp1.ObjectFactory) ExtensionType(com.helger.xsds.peppol.smp1.ExtensionType) Test(org.junit.Test)

Aggregations

JAXBElement (javax.xml.bind.JAXBElement)35 Test (org.junit.Test)29 ArrayList (java.util.ArrayList)26 Marshaller (javax.xml.bind.Marshaller)24 ObjectFactory (net.opengis.cat.csw.v_2_0_2.ObjectFactory)20 StringWriter (java.io.StringWriter)19 JAXBContext (javax.xml.bind.JAXBContext)19 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)18 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)17 ObjectFactory (no.seres.xsd.nav.inntektsmelding_m._20181211.ObjectFactory)16 QName (javax.xml.namespace.QName)15 BigInteger (java.math.BigInteger)13 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)13 XStream (com.thoughtworks.xstream.XStream)12 ByteArrayInputStream (java.io.ByteArrayInputStream)12 GetRecordsResponseType (net.opengis.cat.csw.v_2_0_2.GetRecordsResponseType)12 SearchResultsType (net.opengis.cat.csw.v_2_0_2.SearchResultsType)12 ObjectFactory (slash.navigation.kml.binding22.ObjectFactory)12 ObjectFactory (com.opensymphony.xwork2.ObjectFactory)11 ElementSetNameType (net.opengis.cat.csw.v_2_0_2.ElementSetNameType)11