|
@@ -13,7 +13,7 @@ coords_list = reqparse.RequestParser(bundle_errors=True)
|
|
coords_list.add_argument('coords_list', type=str, required=True, location='form', help='点数组 [[x ,y], [x, y]]')
|
|
coords_list.add_argument('coords_list', type=str, required=True, location='form', help='点数组 [[x ,y], [x, y]]')
|
|
|
|
|
|
|
|
|
|
-@ns.route('/sh2000_to_wgs84')
|
|
|
|
|
|
+# @ns.route('/sh2000_to_wgs84')
|
|
class Sh2000ToWgs84(Resource):
|
|
class Sh2000ToWgs84(Resource):
|
|
|
|
|
|
@ns.doc(description='上海2000转wgs84')
|
|
@ns.doc(description='上海2000转wgs84')
|
|
@@ -51,7 +51,7 @@ class Sh2000ToWgs84(Resource):
|
|
return jsonify(code=StatesCode.UNKNOWN_ERROR, message='失败', data=str(e))
|
|
return jsonify(code=StatesCode.UNKNOWN_ERROR, message='失败', data=str(e))
|
|
|
|
|
|
|
|
|
|
-@ns.route('/urban construction_to_wgs84')
|
|
|
|
|
|
+# @ns.route('/urban construction_to_wgs84')
|
|
class UrbanConstruction(Resource):
|
|
class UrbanConstruction(Resource):
|
|
|
|
|
|
@ns.doc(description='城地转wgs84')
|
|
@ns.doc(description='城地转wgs84')
|
|
@@ -86,3 +86,86 @@ class UrbanConstruction(Resource):
|
|
return jsonify(code=StatesCode.SUCCESS, message='成功', data=coords)
|
|
return jsonify(code=StatesCode.SUCCESS, message='成功', data=coords)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
return jsonify(code=StatesCode.UNKNOWN_ERROR, message='失败', data=str(e))
|
|
return jsonify(code=StatesCode.UNKNOWN_ERROR, message='失败', data=str(e))
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+coords = reqparse.RequestParser(bundle_errors=True)
|
|
|
|
+coords.add_argument('x', type=str, required=True, location='args', help='x')
|
|
|
|
+coords.add_argument('y', type=str, required=True, location='args', help='y')
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+@ns.route('/coord_sh2000_to_wgs84')
|
|
|
|
+class Sh2000ToWgs84(Resource):
|
|
|
|
+ @ns.doc(description='上海2000转wgs84')
|
|
|
|
+ @ns.expect(coords)
|
|
|
|
+ def get(self):
|
|
|
|
+ """上海2000转wgs84"""
|
|
|
|
+
|
|
|
|
+ x = request.args.get('x')
|
|
|
|
+ y = request.args.get('y')
|
|
|
|
+
|
|
|
|
+ if x and y:
|
|
|
|
+ x = float(x)
|
|
|
|
+ y = float(y)
|
|
|
|
+ else:
|
|
|
|
+ return jsonify(code=StatesCode.PARA_ERROR, message='坐标点不能为空')
|
|
|
|
+
|
|
|
|
+ try:
|
|
|
|
+ wkt_path = os.path.join(
|
|
|
|
+ os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))),
|
|
|
|
+ 'config', '上海2000.prj'
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ with open(wkt_path, 'r') as f:
|
|
|
|
+ wkt_str = f.read()
|
|
|
|
+
|
|
|
|
+ srs_source = osr.SpatialReference()
|
|
|
|
+ srs_source.ImportFromWkt(wkt_str)
|
|
|
|
+
|
|
|
|
+ srs_dest = osr.SpatialReference()
|
|
|
|
+ srs_dest.ImportFromEPSG(4326)
|
|
|
|
+
|
|
|
|
+ transform = osr.CoordinateTransformation(srs_source, srs_dest)
|
|
|
|
+ coords = transform.TransformPoint(x, y)
|
|
|
|
+
|
|
|
|
+ return jsonify(code=StatesCode.SUCCESS, message='成功', data=coords)
|
|
|
|
+ except Exception as e:
|
|
|
|
+ return jsonify(code=StatesCode.UNKNOWN_ERROR, message='失败', data=str(e))
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+@ns.route('/coord_urban construction_to_wgs84')
|
|
|
|
+class UrbanConstruction(Resource):
|
|
|
|
+
|
|
|
|
+ @ns.doc(description='城地转wgs84')
|
|
|
|
+ @ns.expect(coords)
|
|
|
|
+ def get(self):
|
|
|
|
+ """城地转wgs84"""
|
|
|
|
+ x = request.args.get('x')
|
|
|
|
+ y = request.args.get('y')
|
|
|
|
+
|
|
|
|
+ if x and y:
|
|
|
|
+ x = float(x)
|
|
|
|
+ y = float(y)
|
|
|
|
+ else:
|
|
|
|
+ return jsonify(code=StatesCode.PARA_ERROR, message='坐标点不能为空')
|
|
|
|
+
|
|
|
|
+ try:
|
|
|
|
+ wkt_path = os.path.join(
|
|
|
|
+ os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))),
|
|
|
|
+ 'config', '城地转84.prj'
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ with open(wkt_path, 'r') as f:
|
|
|
|
+ wkt_str = f.read()
|
|
|
|
+
|
|
|
|
+ srs_source = osr.SpatialReference()
|
|
|
|
+ srs_source.ImportFromWkt(wkt_str)
|
|
|
|
+
|
|
|
|
+ srs_dest = osr.SpatialReference()
|
|
|
|
+ srs_dest.ImportFromEPSG(4326)
|
|
|
|
+
|
|
|
|
+ transform = osr.CoordinateTransformation(srs_source, srs_dest)
|
|
|
|
+ coords = transform.TransformPoint(x, y)
|
|
|
|
+
|
|
|
|
+ return jsonify(code=StatesCode.SUCCESS, message='成功', data=coords)
|
|
|
|
+ except Exception as e:
|
|
|
|
+ return jsonify(code=StatesCode.UNKNOWN_ERROR, message='失败', data=str(e))
|