Exemplo n.º 1
0
def update_default_geometry(
        old_main_waypoint_id, linked_waypoints, route, route_in, user_id):
    geometry = route.geometry
    geometry_in = route_in.geometry
    if geometry_in is not None and geometry_in.geom is not None:
        # default geom is manually set in the request
        return
    elif geometry_in is not None and geometry_in.geom_detail is not None:
        # update the default geom with the new track
        geometry.geom = get_mid_point(geometry.geom_detail)
        return
    elif geometry is not None and geometry.geom_detail is not None:
        # default geom is already set and no new track is provided
        return
    elif geometry is None or geometry.geom_detail is None:
        # only update if no own track
        if route.main_waypoint_id and \
                main_waypoint_has_changed(route, old_main_waypoint_id):
            main_wp_point = _get_default_geom_from_main_wp(route)
            if main_wp_point is not None:
                if geometry is not None:
                    route.geometry.geom = main_wp_point
                else:
                    route.geometry = DocumentGeometry(geom=main_wp_point)
                return

    set_default_geom_from_associations(
        route, linked_waypoints, update_always=True)
Exemplo n.º 2
0
def update_default_geometry(outing, outing_in):
    """When updating an outing, set the default geometry to the middle point
    of a new track if proovided
    """

    geometry_in = outing_in.geometry

    if geometry_in is not None and geometry_in.geom_detail is not None:
        # update the default geom with the new track
        geometry_in.geom = get_mid_point(geometry_in.geom_detail)
Exemplo n.º 3
0
def update_default_geometry(outing, outing_in, user_id):
    """When updating an outing, set the default geometry to the middle point
    of a new track, or directly update with a given geometry.
    """
    # TODO also use geometry of main waypoint when main waypoint has changed?
    geometry_in = outing_in.geometry
    if geometry_in is not None and geometry_in.geom is not None:
        # default geom is manually set in the request
        return
    elif geometry_in is not None and geometry_in.geom_detail is not None:
        # update the default geom with the new track
        outing.geometry.geom = get_mid_point(outing.geometry.geom_detail)
Exemplo n.º 4
0
def update_default_geometry(outing, outing_in, user_id):
    """When updating an outing, set the default geometry to the middle point
    of a new track, or directly update with a given geometry.
    """
    # TODO also use geometry of main waypoint when main waypoint has changed?
    geometry_in = outing_in.geometry
    if geometry_in is not None and geometry_in.geom is not None:
        # default geom is manually set in the request
        return
    elif geometry_in is not None and geometry_in.geom_detail is not None:
        # update the default geom with the new track
        outing.geometry.geom = get_mid_point(outing.geometry.geom_detail)
Exemplo n.º 5
0
def set_default_geometry(linked_routes, outing, user_id):
    """When creating a new outing, set the default geometry to the middle point
    of a given track, if not to the centroid of the convex hull
    of all associated routes.
    """
    if outing.geometry is not None and outing.geometry.geom is not None:
        # default geometry already set
        return

    if outing.geometry is not None and outing.geometry.geom_detail is not None:
        # track is given, obtain a default point from the track
        outing.geometry.geom = get_mid_point(outing.geometry.geom_detail)
        return

    set_default_geom_from_associations(outing, linked_routes)
Exemplo n.º 6
0
def set_default_geometry(linked_routes, outing, user_id):
    """When creating a new outing, set the default geometry to the middle point
    of a given track, if not to the centroid of the convex hull
    of all associated routes.
    """
    if outing.geometry is not None and outing.geometry.geom is not None:
        # default geometry already set
        return

    if outing.geometry is not None and outing.geometry.geom_detail is not None:
        # track is given, obtain a default point from the track
        outing.geometry.geom = get_mid_point(outing.geometry.geom_detail)
        return

    set_default_geom_from_associations(outing, linked_routes)
Exemplo n.º 7
0
def set_default_geometry(route, user_id):
    """When creating a new route, set the default geometry to the middle point
    of a given track, if not to the geometry of the associated main waypoint.
    """
    if route.geometry is not None and route.geometry.geom is not None:
        # default geometry already set
        return

    if route.geometry is not None and route.geometry.geom_detail is not None:
        # track is given, obtain a default point from the track
        route.geometry.geom = get_mid_point(route.geometry.geom_detail)
    elif route.main_waypoint_id:
        # get default point from main waypoint
        main_wp_point = DBSession.query(DocumentGeometry.geom).filter(
            DocumentGeometry.document_id == route.main_waypoint_id).scalar()
        if main_wp_point is not None:
            route.geometry = DocumentGeometry(geom=main_wp_point)
Exemplo n.º 8
0
def set_default_geometry(linked_waypoints, route, user_id):
    """When creating a new route, set the default geometry to the middle point
    of a given track, if not to the geometry of the associated main waypoint
    (if a main waypoint is set), otherwise to the centroid of the convex hull
    of all associated waypoints.
    """
    if route.geometry is not None and route.geometry.geom is not None:
        # default geometry already set
        return

    if route.geometry is not None and route.geometry.geom_detail is not None:
        # track is given, obtain a default point from the track
        route.geometry.geom = get_mid_point(route.geometry.geom_detail)
    elif route.main_waypoint_id:
        _set_default_geom_from_main_wp(route)

    set_default_geom_from_associations(route, linked_waypoints)
Exemplo n.º 9
0
def set_default_geometry(linked_waypoints, route, user_id):
    """When creating a new route, set the default geometry to the middle point
    of a given track, if not to the geometry of the associated main waypoint
    (if a main waypoint is set), otherwise to the centroid of the convex hull
    of all associated waypoints.
    """
    if route.geometry is not None and route.geometry.geom is not None:
        # default geometry already set
        return

    if route.geometry is not None and route.geometry.geom_detail is not None:
        # track is given, obtain a default point from the track
        route.geometry.geom = get_mid_point(route.geometry.geom_detail)
    elif route.main_waypoint_id:
        _set_default_geom_from_main_wp(route)

    set_default_geom_from_associations(route, linked_waypoints)
Exemplo n.º 10
0
def set_default_geometry(route, user_id):
    """When creating a new route, set the default geometry to the middle point
    of a given track, if not to the geometry of the associated main waypoint.
    """
    if route.geometry is not None and route.geometry.geom is not None:
        # default geometry already set
        return

    if route.geometry is not None and route.geometry.geom_detail is not None:
        # track is given, obtain a default point from the track
        route.geometry.geom = get_mid_point(route.geometry.geom_detail)
    elif route.main_waypoint_id:
        # get default point from main waypoint
        main_wp_point = DBSession.query(DocumentGeometry.geom).filter(
            DocumentGeometry.document_id == route.main_waypoint_id).scalar()
        if main_wp_point is not None:
            route.geometry = DocumentGeometry(geom=main_wp_point)
Exemplo n.º 11
0
def set_default_geometry(linked_routes, outing, user_id):
    """When creating a new outing, set the default geometry to the middle point
    of a given track, if not to the geometry of an associated route.
    """
    if outing.geometry is not None and outing.geometry.geom is not None:
        # default geometry already set
        return

    if outing.geometry is not None and outing.geometry.geom_detail is not None:
        # track is given, obtain a default point from the track
        outing.geometry.geom = get_mid_point(outing.geometry.geom_detail)
    elif linked_routes:
        route_id = linked_routes[0]['document_id']
        # get default point from route
        route_point = DBSession.query(DocumentGeometry.geom).filter(
            DocumentGeometry.document_id == route_id).scalar()
        if route_point is not None:
            outing.geometry = DocumentGeometry(geom=route_point)
Exemplo n.º 12
0
def set_default_geometry(linked_routes, outing, user_id):
    """When creating a new outing, set the default geometry to the middle point
    of a given track, if not to the geometry of an associated route.
    """
    if outing.geometry is not None and outing.geometry.geom is not None:
        # default geometry already set
        return

    if outing.geometry is not None and outing.geometry.geom_detail is not None:
        # track is given, obtain a default point from the track
        outing.geometry.geom = get_mid_point(outing.geometry.geom_detail)
    elif linked_routes:
        route_id = linked_routes[0]['document_id']
        # get default point from route
        route_point = DBSession.query(DocumentGeometry.geom).filter(
            DocumentGeometry.document_id == route_id).scalar()
        if route_point is not None:
            outing.geometry = DocumentGeometry(geom=route_point)
Exemplo n.º 13
0
def update_default_geometry(old_main_waypoint_id, route, route_in, user_id):
    geometry_in = route_in.geometry
    if geometry_in is not None and geometry_in.geom is not None:
        # default geom is manually set in the request
        return
    elif geometry_in is not None and geometry_in.geom_detail is not None:
        # update the default geom with the new track
        route.geometry.geom = get_mid_point(route.geometry.geom_detail)
    elif main_waypoint_has_changed(route_in, old_main_waypoint_id):
        # when the main waypoint has changed, use the waypoint geom
        main_wp_point = DBSession.query(DocumentGeometry.geom).filter(
            DocumentGeometry.document_id == route.main_waypoint_id).scalar()
        if main_wp_point is not None:
            if route.geometry is not None:
                if route.geometry.geom_detail is None:
                    # only update if no own track
                    route.geometry.geom = main_wp_point
            else:
                route.geometry = DocumentGeometry(geom=main_wp_point)
Exemplo n.º 14
0
def update_default_geometry(old_main_waypoint_id, route, route_in, user_id):
    geometry_in = route_in.geometry
    if geometry_in is not None and geometry_in.geom is not None:
        # default geom is manually set in the request
        return
    elif geometry_in is not None and geometry_in.geom_detail is not None:
        # update the default geom with the new track
        route.geometry.geom = get_mid_point(route.geometry.geom_detail)
    elif main_waypoint_has_changed(route_in, old_main_waypoint_id):
        # when the main waypoint has changed, use the waypoint geom
        main_wp_point = DBSession.query(DocumentGeometry.geom).filter(
            DocumentGeometry.document_id == route.main_waypoint_id).scalar()
        if main_wp_point is not None:
            if route.geometry is not None:
                if route.geometry.geom_detail is None:
                    # only update if no own track
                    route.geometry.geom = main_wp_point
            else:
                route.geometry = DocumentGeometry(geom=main_wp_point)
Exemplo n.º 15
0
def update_default_geometry(linked_routes, outing, outing_in, user_id):
    """When updating an outing, set the default geometry to the middle point
    of a new track, if not to the centroid of the convex hull
    of all associated routes.
    """
    geometry = outing.geometry
    geometry_in = outing_in.geometry
    if geometry_in is not None and geometry_in.geom is not None:
        # default geom is manually set in the request
        return
    elif geometry_in is not None and geometry_in.geom_detail is not None:
        # update the default geom with the new track
        geometry.geom = get_mid_point(geometry.geom_detail)
        return
    elif geometry is not None and geometry.geom_detail is not None:
        # default geom is already set and no new track is provided
        return

    set_default_geom_from_associations(
        outing, linked_routes, update_always=True)
Exemplo n.º 16
0
def update_default_geometry(linked_routes, outing, outing_in, user_id):
    """When updating an outing, set the default geometry to the middle point
    of a new track, if not to the centroid of the convex hull
    of all associated routes.
    """
    geometry = outing.geometry
    geometry_in = outing_in.geometry
    if geometry_in is not None and geometry_in.geom is not None:
        # default geom is manually set in the request
        return
    elif geometry_in is not None and geometry_in.geom_detail is not None:
        # update the default geom with the new track
        geometry.geom = get_mid_point(geometry.geom_detail)
        return
    elif geometry is not None and geometry.geom_detail is not None:
        # default geom is already set and no new track is provided
        return

    set_default_geom_from_associations(outing,
                                       linked_routes,
                                       update_always=True)