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)
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)
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)
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)
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)