正在显示
2 个修改的文件
包含
35 行增加
和
30 行删除
| @@ -21,9 +21,8 @@ from app.util.component.TaskController import TaskController | @@ -21,9 +21,8 @@ from app.util.component.TaskController import TaskController | ||
| 21 | from app.util.component.TaskWriter import TaskWriter | 21 | from app.util.component.TaskWriter import TaskWriter |
| 22 | from osgeo.ogr import DataSource,Layer,Geometry | 22 | from osgeo.ogr import DataSource,Layer,Geometry |
| 23 | from osgeo import ogr | 23 | from osgeo import ogr |
| 24 | -from authlib.integrations.flask_oauth2 import current_token | ||
| 25 | from app.util.component.UserCheck import UserCheck | 24 | from app.util.component.UserCheck import UserCheck |
| 26 | - | 25 | +import copy |
| 27 | 26 | ||
| 28 | 27 | ||
| 29 | class Api(ApiTemplate): | 28 | class Api(ApiTemplate): |
| @@ -317,8 +316,8 @@ class VacuateProcess: | @@ -317,8 +316,8 @@ class VacuateProcess: | ||
| 317 | 316 | ||
| 318 | schema = layer.schema | 317 | schema = layer.schema |
| 319 | # 增加统计字段 | 318 | # 增加统计字段 |
| 320 | - schema.append(ogr.FieldDefn("_dcigrid_count_", ogr.OFTInteger)) | ||
| 321 | - schema.append(ogr.FieldDefn("_dcigrid_name_", ogr.OFTString)) | 319 | + # schema.append(ogr.FieldDefn("_dcigrid_count_", ogr.OFTInteger)) |
| 320 | + # schema.append(ogr.FieldDefn("_dcigrid_name_", ogr.OFTString)) | ||
| 322 | 321 | ||
| 323 | for l in range(self.max_level): | 322 | for l in range(self.max_level): |
| 324 | this_grid_len = self.this_gridsize[l] | 323 | this_grid_len = self.this_gridsize[l] |
| @@ -354,7 +353,7 @@ class VacuateProcess: | @@ -354,7 +353,7 @@ class VacuateProcess: | ||
| 354 | def vacuate(self,g,feature): | 353 | def vacuate(self,g,feature): |
| 355 | 354 | ||
| 356 | if self.is_spatial: | 355 | if self.is_spatial: |
| 357 | - | 356 | + feat = copy.copy(feature) |
| 358 | # 插入到所有抽稀图层中 | 357 | # 插入到所有抽稀图层中 |
| 359 | for level in range(self.max_level): | 358 | for level in range(self.max_level): |
| 360 | 359 | ||
| @@ -375,7 +374,9 @@ class VacuateProcess: | @@ -375,7 +374,9 @@ class VacuateProcess: | ||
| 375 | if self.fill_dict[key] == 0: | 374 | if self.fill_dict[key] == 0: |
| 376 | 375 | ||
| 377 | vacuate_layer: Layer = self.vacuate_layers.get(level) | 376 | vacuate_layer: Layer = self.vacuate_layers.get(level) |
| 378 | - feat = ogr.Feature(vacuate_layer.GetLayerDefn()) | 377 | + |
| 378 | + | ||
| 379 | + #feat = ogr.Feature(vacuate_layer.GetLayerDefn()) | ||
| 379 | # 如果图形比网格小,直接存储其中心点 | 380 | # 如果图形比网格小,直接存储其中心点 |
| 380 | if this_grid_len>long_extent and this_grid_len>lat_extent: | 381 | if this_grid_len>long_extent and this_grid_len>lat_extent: |
| 381 | feat.SetGeometry(center) | 382 | feat.SetGeometry(center) |
| @@ -383,27 +384,28 @@ class VacuateProcess: | @@ -383,27 +384,28 @@ class VacuateProcess: | ||
| 383 | feat.SetGeometry(g) | 384 | feat.SetGeometry(g) |
| 384 | 385 | ||
| 385 | # 复制旧feature属性 | 386 | # 复制旧feature属性 |
| 386 | - field_dict = feature.items() | ||
| 387 | - for field_name in field_dict: | ||
| 388 | - feat.SetField(field_name, field_dict[field_name]) | ||
| 389 | - | ||
| 390 | - feat.SetField("_dcigrid_name_",".".join(key.split(".")[1:])) | 387 | + # field_dict = feature.items() |
| 388 | + # for field_name in field_dict: | ||
| 389 | + # feat.SetField(field_name, field_dict[field_name]) | ||
| 390 | + # | ||
| 391 | + # feat.SetField("_dcigrid_name_",".".join(key.split(".")[1:])) | ||
| 391 | 392 | ||
| 392 | vacuate_layer.CreateFeature(feat) | 393 | vacuate_layer.CreateFeature(feat) |
| 394 | + | ||
| 393 | self.fill_dict[key] += 1 | 395 | self.fill_dict[key] += 1 |
| 394 | #超大的还有机会 | 396 | #超大的还有机会 |
| 395 | elif long_extent > 10 * this_grid_len or lat_extent > 10 * this_grid_len: | 397 | elif long_extent > 10 * this_grid_len or lat_extent > 10 * this_grid_len: |
| 396 | vacuate_layer: Layer = self.vacuate_layers.get(level) | 398 | vacuate_layer: Layer = self.vacuate_layers.get(level) |
| 397 | 399 | ||
| 400 | + # feat = ogr.Feature(vacuate_layer.GetLayerDefn()) | ||
| 398 | 401 | ||
| 399 | - feat = ogr.Feature(vacuate_layer.GetLayerDefn()) | ||
| 400 | feat.SetGeometry(g) | 402 | feat.SetGeometry(g) |
| 401 | 403 | ||
| 402 | # 复制旧feature属性 | 404 | # 复制旧feature属性 |
| 403 | - field_dict = feature.items() | ||
| 404 | - for field_name in field_dict: | ||
| 405 | - feat.SetField(field_name, field_dict[field_name]) | ||
| 406 | - feat.SetField("_dcigrid_name_",".".join(key.split(".")[1:])) | 405 | + # field_dict = feature.items() |
| 406 | + # for field_name in field_dict: | ||
| 407 | + # feat.SetField(field_name, field_dict[field_name]) | ||
| 408 | + # feat.SetField("_dcigrid_name_",".".join(key.split(".")[1:])) | ||
| 407 | 409 | ||
| 408 | vacuate_layer.CreateFeature(feat) | 410 | vacuate_layer.CreateFeature(feat) |
| 409 | self.fill_dict[key] += 1 | 411 | self.fill_dict[key] += 1 |
| @@ -18,6 +18,7 @@ from app.util.component.UserCheck import UserCheck | @@ -18,6 +18,7 @@ from app.util.component.UserCheck import UserCheck | ||
| 18 | from app.util.component.VacuateConf import VacuateConf | 18 | from app.util.component.VacuateConf import VacuateConf |
| 19 | from app.util.component.TaskController import TaskController | 19 | from app.util.component.TaskController import TaskController |
| 20 | from app.util.component.TaskWriter import TaskWriter | 20 | from app.util.component.TaskWriter import TaskWriter |
| 21 | +import copy | ||
| 21 | 22 | ||
| 22 | class Api(ApiTemplate): | 23 | class Api(ApiTemplate): |
| 23 | api_name = "单独抽稀" | 24 | api_name = "单独抽稀" |
| @@ -150,7 +151,7 @@ class Api(ApiTemplate): | @@ -150,7 +151,7 @@ class Api(ApiTemplate): | ||
| 150 | if count%10000==0: | 151 | if count%10000==0: |
| 151 | StructurePrint().print("{}图层已抽稀{}个对象".format(table.name, count)) | 152 | StructurePrint().print("{}图层已抽稀{}个对象".format(table.name, count)) |
| 152 | 153 | ||
| 153 | - vacuate_process.set_vacuate_count() | 154 | + # vacuate_process.set_vacuate_count() |
| 154 | 155 | ||
| 155 | 156 | ||
| 156 | #新增 | 157 | #新增 |
| @@ -281,8 +282,8 @@ class VacuateProcess: | @@ -281,8 +282,8 @@ class VacuateProcess: | ||
| 281 | 282 | ||
| 282 | schema = layer.schema | 283 | schema = layer.schema |
| 283 | # 增加统计字段 | 284 | # 增加统计字段 |
| 284 | - schema.append(ogr.FieldDefn("_dcigrid_count_", ogr.OFTInteger)) | ||
| 285 | - schema.append(ogr.FieldDefn("_dcigrid_name_", ogr.OFTString)) | 285 | + # schema.append(ogr.FieldDefn("_dcigrid_count_", ogr.OFTInteger)) |
| 286 | + # schema.append(ogr.FieldDefn("_dcigrid_name_", ogr.OFTString)) | ||
| 286 | 287 | ||
| 287 | for l in range(self.max_level): | 288 | for l in range(self.max_level): |
| 288 | this_grid_len = self.this_gridsize[l] | 289 | this_grid_len = self.this_gridsize[l] |
| @@ -322,7 +323,7 @@ class VacuateProcess: | @@ -322,7 +323,7 @@ class VacuateProcess: | ||
| 322 | def vacuate(self,g,feature): | 323 | def vacuate(self,g,feature): |
| 323 | 324 | ||
| 324 | if self.is_spatial: | 325 | if self.is_spatial: |
| 325 | - | 326 | + feat = copy.copy(feature) |
| 326 | # 插入到所有抽稀图层中 | 327 | # 插入到所有抽稀图层中 |
| 327 | for level in range(self.max_level): | 328 | for level in range(self.max_level): |
| 328 | 329 | ||
| @@ -344,7 +345,8 @@ class VacuateProcess: | @@ -344,7 +345,8 @@ class VacuateProcess: | ||
| 344 | if self.fill_dict[key] == 0: | 345 | if self.fill_dict[key] == 0: |
| 345 | 346 | ||
| 346 | vacuate_layer: Layer = self.vacuate_layers.get(level) | 347 | vacuate_layer: Layer = self.vacuate_layers.get(level) |
| 347 | - feat = ogr.Feature(vacuate_layer.GetLayerDefn()) | 348 | + |
| 349 | + # feat = ogr.Feature(vacuate_layer.GetLayerDefn()) | ||
| 348 | # 如果图形比网格小,直接存储其中心点 | 350 | # 如果图形比网格小,直接存储其中心点 |
| 349 | if this_grid_len>long_extent and this_grid_len>lat_extent: | 351 | if this_grid_len>long_extent and this_grid_len>lat_extent: |
| 350 | feat.SetGeometry(center) | 352 | feat.SetGeometry(center) |
| @@ -352,10 +354,10 @@ class VacuateProcess: | @@ -352,10 +354,10 @@ class VacuateProcess: | ||
| 352 | feat.SetGeometry(g) | 354 | feat.SetGeometry(g) |
| 353 | 355 | ||
| 354 | # 复制旧feature属性 | 356 | # 复制旧feature属性 |
| 355 | - field_dict = feature.items() | ||
| 356 | - for field_name in field_dict: | ||
| 357 | - feat.SetField(field_name, field_dict[field_name]) | ||
| 358 | - feat.SetField("_dcigrid_name_",".".join(key.split(".")[1:])) | 357 | + # field_dict = feature.items() |
| 358 | + # for field_name in field_dict: | ||
| 359 | + # feat.SetField(field_name, field_dict[field_name]) | ||
| 360 | + # feat.SetField("_dcigrid_name_",".".join(key.split(".")[1:])) | ||
| 359 | 361 | ||
| 360 | vacuate_layer.CreateFeature(feat) | 362 | vacuate_layer.CreateFeature(feat) |
| 361 | self.fill_dict[key] += 1 | 363 | self.fill_dict[key] += 1 |
| @@ -363,14 +365,15 @@ class VacuateProcess: | @@ -363,14 +365,15 @@ class VacuateProcess: | ||
| 363 | #超大的还有机会 | 365 | #超大的还有机会 |
| 364 | elif long_extent > 10 * this_grid_len or lat_extent > 10 * this_grid_len: | 366 | elif long_extent > 10 * this_grid_len or lat_extent > 10 * this_grid_len: |
| 365 | vacuate_layer: Layer = self.vacuate_layers.get(level) | 367 | vacuate_layer: Layer = self.vacuate_layers.get(level) |
| 366 | - feat = ogr.Feature(vacuate_layer.GetLayerDefn()) | 368 | + |
| 369 | + # feat = ogr.Feature(vacuate_layer.GetLayerDefn()) | ||
| 367 | feat.SetGeometry(g) | 370 | feat.SetGeometry(g) |
| 368 | 371 | ||
| 369 | # 复制旧feature属性 | 372 | # 复制旧feature属性 |
| 370 | - field_dict = feature.items() | ||
| 371 | - for field_name in field_dict: | ||
| 372 | - feat.SetField(field_name, field_dict[field_name]) | ||
| 373 | - feat.SetField("_dcigrid_name_",".".join(key.split(".")[1:])) | 373 | + # field_dict = feature.items() |
| 374 | + # for field_name in field_dict: | ||
| 375 | + # feat.SetField(field_name, field_dict[field_name]) | ||
| 376 | + # feat.SetField("_dcigrid_name_",".".join(key.split(".")[1:])) | ||
| 374 | 377 | ||
| 375 | vacuate_layer.CreateFeature(feat) | 378 | vacuate_layer.CreateFeature(feat) |
| 376 | self.fill_dict[key] += 1 | 379 | self.fill_dict[key] += 1 |
请
注册
或
登录
后发表评论