正在显示
2 个修改的文件
包含
25 行增加
和
17 行删除
| ... | ... | @@ -12,10 +12,11 @@ from app.util.component.PGUtil import PGUtil |
| 12 | 12 | from app.util.component.GeometryAdapter import GeometryAdapter |
| 13 | 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 | 17 | from app.util.component.VacuateConf import VacuateConf |
| 18 | 18 | import copy |
| 19 | +import json | |
| 19 | 20 | class Api(ApiTemplate): |
| 20 | 21 | api_name = "推荐抽稀" |
| 21 | 22 | def process(self): |
| ... | ... | @@ -36,7 +37,7 @@ class Api(ApiTemplate): |
| 36 | 37 | # 判断图层是否存在 |
| 37 | 38 | |
| 38 | 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 | 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 | 66 | fill_precent = 0 |
| 65 | 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 | 70 | grid_extent = [extent[0] + ix * p_x, extent[0] + ix * p_x + p_x, extent[2] + iy * p_y, |
| 69 | 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 | 87 | StructurePrint().print("判断疏密结束") |
| 80 | 88 | |
| 81 | 89 | layer.SetSpatialFilter(None) | ... | ... |
| ... | ... | @@ -4,7 +4,7 @@ |
| 4 | 4 | #email: nheweijun@sina.com |
| 5 | 5 | |
| 6 | 6 | from app.util.component.ApiTemplate import ApiTemplate |
| 7 | -from app.util.component.StructurePrint import StructurePrint | |
| 7 | + | |
| 8 | 8 | from app.util.component.ModelVisitor import ModelVisitor |
| 9 | 9 | import uuid |
| 10 | 10 | from ..models import TileService,Service,db,ServiceFunction,TileScheme | ... | ... |
请
注册
或
登录
后发表评论