Exemple #1
0
def snap2grid(obj_gps, zoom = ZOOM_LEVEL, img_size = IMAGE_SIZE, overlap=.1):
    img_size = img_size - img_size*overlap
    scale = 2.**zoom
    proj = MercatorProjection()
    objPx = proj.fromLatLngToPoint(G_LatLng(obj_gps[1], obj_gps[0]))
    def myround(num):
        return np.round(num*scale/img_size)*img_size/scale
    centerPx = G_Point( myround(objPx.x), myround(objPx.y))
    center_gps = proj.fromPointToLatLng(centerPx)
    return [np.round(center_gps.lng,6), np.round(center_gps.lat,6)]
Exemple #2
0
def labels_GPS(labels, center_gps, pixels = PIXELperLABEL, zoom = ZOOM_LEVEL):
    scale = 2.**zoom
    proj = MercatorProjection()
    centerPx = proj.fromLatLngToPoint(G_LatLng(center_gps[1], center_gps[0]))
    suspect_x, suspect_y = labels_suspect(labels, pixels)
    np_gps = np.zeros((len(suspect_x),2))
    for i in range(len(suspect_x)):
        suspectPX = G_Point(centerPx.x+suspect_x[i]/scale, centerPx.y+suspect_y[i]/scale)
        suspect_gps = proj.fromPointToLatLng(suspectPX)
        np_gps[i,] = [suspect_gps.lng, suspect_gps.lat]
    return np_gps