示例#1
0
文件: route.py 项目: sriks123/v6_api
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)
示例#2
0
文件: outing.py 项目: c2corg/v6_api
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)
示例#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)
示例#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)
示例#5
0
文件: outing.py 项目: c2corg/v6_api
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)
示例#6
0
文件: outing.py 项目: c2corg/v6_api
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)
示例#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)
示例#8
0
文件: route.py 项目: c2corg/v6_api
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)
示例#9
0
文件: route.py 项目: c2corg/v6_api
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)
示例#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)
示例#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)
示例#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)
示例#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)
示例#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)
示例#15
0
文件: outing.py 项目: c2corg/v6_api
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)
示例#16
0
文件: outing.py 项目: sriks123/v6_api
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)