from .coordTransform_utils import wgs84togcj02, gcj02towgs84, gcj02tobd09, bd09togcj02


def wgs84tobd09(lng, lat):
    tmp_lng, tmp_lat = wgs84togcj02(lng, lat)
    return gcj02tobd09(tmp_lng, tmp_lat)


def bd09towgs84(lng, lat):
    tmp_lng, tmp_lat = bd09togcj02(lng, lat)
    return gcj02towgs84(tmp_lng, tmp_lat)

methods = {
    "wgs2gcj": wgs84togcj02,
    "gcj2wgs": gcj02towgs84,
    "wgs2bd": wgs84tobd09,
    "bd2wgs": bd09towgs84,
    "gcj2bd": gcj02tobd09,
    "bd2gcj": bd09towgs84
}


def convertor(geometry, method="wgs2gcj"):
    """
    convert wgs84 to gcj
    referencing by https://github.com/wandergis/coordTransform_py
    """
    # TODO: point linestring point
    if geometry['type'] == 'MultiLineString':
        coordinates = geometry['coordinates']
        for lines in coordinates:
            for line in lines:
                line[0], line[1] = methods[method](line[0], line[1])

    return geometry



@@ -652,147 +652,761 @@
     
-# TODO: point lines
+if geometry%5B'type'%5D == 'Point':%0A        coords = geometry%5B'coordinates'%5D%0A        coords%5B0%5D, coords%5B1%5D = methods%5Bmethod%5D(coords%5B0%5D, coords%5B1%5D)%0A    elif geometry%5B'type'%5D == 'LineS
 tring
- point%0A    if geometry%5B'type'%5D == 'MultiLineString':%0A        coordinates = geometry%5B'coordinates'%5D%0A        for line
+' or geometry%5B'type'%5D == 'MutliPoint':%0A        coordinates = geometry%5B'coordinates'%5D%0A        for coords in coordinates:%0A            coords%5B0%5D, coords%5B1%5D = methods%5Bmethod%5D(coords%5B0%5D, coords%5B1%5D)%0A    elif geometry%5B'type'%5D == 'Polygon' or geometry%5B'type'%5D == 'MultiLineString':%0A        coordinates = geometry%5B'coordinates'%5D%0A        for rings in coordinates:%0A            for coords in rings:%0A                coords%5B0%5D, coords%5B1%5D = methods%5Bmethod%5D(coords%5B0%5D, coords%5B1%5D)%0A    elif geometry%5B'type'%5D == 'MultiPolygon':%0A        coordinates = geometry%5B'coordinates'%5D%0A        for ring
 s in
@@ -1443,16 +1443,17 @@
 line
+s
  in 
-line
+ring
 s:%0A 
@@ -1467,29 +1467,74 @@
         
-line%5B0%5D, line
+for coords in lines:%0A                    coords%5B0%5D, coords
 %5B1%5D = me
@@ -1551,27 +1551,30 @@
 od%5D(
-line%5B0%5D, line
+coords%5B0%5D, coords
 %5B1%5D)%0A
-%0A
     

add different type support