正在显示
2 个修改的文件
包含
25 行增加
和
17 行删除
@@ -12,10 +12,11 @@ from app.util.component.PGUtil import PGUtil | @@ -12,10 +12,11 @@ from app.util.component.PGUtil import PGUtil | ||
12 | from app.util.component.GeometryAdapter import GeometryAdapter | 12 | from app.util.component.GeometryAdapter import GeometryAdapter |
13 | from app.util.component.StructurePrint import StructurePrint | 13 | from app.util.component.StructurePrint import StructurePrint |
14 | 14 | ||
15 | -from osgeo.ogr import DataSource | 15 | +from osgeo.ogr import DataSource,Layer |
16 | 16 | ||
17 | from app.util.component.VacuateConf import VacuateConf | 17 | from app.util.component.VacuateConf import VacuateConf |
18 | import copy | 18 | import copy |
19 | +import json | ||
19 | class Api(ApiTemplate): | 20 | class Api(ApiTemplate): |
20 | api_name = "推荐抽稀" | 21 | api_name = "推荐抽稀" |
21 | def process(self): | 22 | def process(self): |
@@ -36,7 +37,7 @@ class Api(ApiTemplate): | @@ -36,7 +37,7 @@ class Api(ApiTemplate): | ||
36 | # 判断图层是否存在 | 37 | # 判断图层是否存在 |
37 | 38 | ||
38 | pg_ds :DataSource= PGUtil.open_pg_data_source(0,DES.decode(table.relate_database.sqlalchemy_uri)) | 39 | pg_ds :DataSource= PGUtil.open_pg_data_source(0,DES.decode(table.relate_database.sqlalchemy_uri)) |
39 | - layer = pg_ds.GetLayerByName(table.name) | 40 | + layer:Layer = pg_ds.GetLayerByName(table.name) |
40 | 41 | ||
41 | # 判断用户权限 | 42 | # 判断用户权限 |
42 | 43 | ||
@@ -55,27 +56,34 @@ class Api(ApiTemplate): | @@ -55,27 +56,34 @@ class Api(ApiTemplate): | ||
55 | 56 | ||
56 | 57 | ||
57 | # 判断需要抽稀多少级 | 58 | # 判断需要抽稀多少级 |
58 | - lc = layer.GetFeatureCount() | ||
59 | - extent = layer.GetExtent() | ||
60 | - | 59 | + # lc = layer.GetFeatureCount() |
60 | + lc = table.feature_count | ||
61 | + # extent = layer.GetExtent() | ||
62 | + extent = [float(x) for x in table.extent.split(",")] | ||
61 | # 判断疏密程度 | 63 | # 判断疏密程度 |
62 | - p_x = (extent[1] - extent[0]) / 10.0 | ||
63 | - p_y = (extent[3] - extent[2]) / 10.0 | 64 | + p_x = (extent[1] - extent[0]) / 5.0 |
65 | + p_y = (extent[3] - extent[2]) / 5.0 | ||
64 | fill_precent = 0 | 66 | fill_precent = 0 |
65 | StructurePrint().print("判断疏密") | 67 | StructurePrint().print("判断疏密") |
66 | - for ix in range(10): | ||
67 | - for iy in range(10): | 68 | + for ix in range(5): |
69 | + for iy in range(5): | ||
68 | grid_extent = [extent[0] + ix * p_x, extent[0] + ix * p_x + p_x, extent[2] + iy * p_y, | 70 | grid_extent = [extent[0] + ix * p_x, extent[0] + ix * p_x + p_x, extent[2] + iy * p_y, |
69 | extent[2] + iy * p_y + p_y] | 71 | extent[2] + iy * p_y + p_y] |
70 | - poly = GeometryAdapter.envelop_2_polygon(grid_extent) | ||
71 | 72 | ||
72 | - layer.SetSpatialFilter(None) | ||
73 | - layer.SetSpatialFilter(poly) | ||
74 | - layer.ResetReading() | ||
75 | - if layer.GetNextFeature(): | ||
76 | - fill_precent += 1 | 73 | + poly = GeometryAdapter.envelop_2_polygon(grid_extent) |
77 | 74 | ||
78 | - print(fill_precent) | 75 | + sql = '''select * from "{}" where st_intersects({},st_geogfromtext('{}')) limit 1'''.format(layer.GetName(), |
76 | + layer.GetGeometryColumn(),poly.ExportToWkt()) | ||
77 | + query_layer: Layer = pg_ds.ExecuteSQL(sql) | ||
78 | + if query_layer.GetFeatureCount() == 1: | ||
79 | + fill_precent += 4 | ||
80 | + # layer.SetSpatialFilter(None) | ||
81 | + # layer.SetSpatialFilter(poly) | ||
82 | + # layer.ResetReading() | ||
83 | + # if layer.GetNextFeature(): | ||
84 | + # fill_precent += 4 | ||
85 | + | ||
86 | + StructurePrint().print(fill_precent) | ||
79 | StructurePrint().print("判断疏密结束") | 87 | StructurePrint().print("判断疏密结束") |
80 | 88 | ||
81 | layer.SetSpatialFilter(None) | 89 | layer.SetSpatialFilter(None) |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | #email: nheweijun@sina.com | 4 | #email: nheweijun@sina.com |
5 | 5 | ||
6 | from app.util.component.ApiTemplate import ApiTemplate | 6 | from app.util.component.ApiTemplate import ApiTemplate |
7 | -from app.util.component.StructurePrint import StructurePrint | 7 | + |
8 | from app.util.component.ModelVisitor import ModelVisitor | 8 | from app.util.component.ModelVisitor import ModelVisitor |
9 | import uuid | 9 | import uuid |
10 | from ..models import TileService,Service,db,ServiceFunction,TileScheme | 10 | from ..models import TileService,Service,db,ServiceFunction,TileScheme |
请
注册
或
登录
后发表评论