FME 应用cad处理

坐标串生成cad文件

import fme
import fmeobjects
from fmeobjects import FMELogFile
from fmeobjects import FMEFeature, FMEPoint, FMELine, FMEGeometryTools,FMECurve,FMEPolygon


# Template Function interface:
def processFeature(feature):
    pass

# Template Class Interface:
class FeatureProcessor(object):
    def __init__(self):
        pass
    def input(self,feature):
   
        List_counter = feature.getAttribute('_element_count')
        
        points = []
        for i in range(int(List_counter)):
            x = feature.getAttribute('_list{'+str(i)+'}.X')
            y = feature.getAttribute('_list{'+str(i)+'}.Y')
            
            point = FMEPoint(x,y)
            
            #points.append(point)
            
            points.append((x,y))
            #FMELogFile().logMessageString(str(point))
        
        curve = FMELine(points)
        
        ploygon = FMEPolygon(curve)
              
        #FMELogFile().logMessageString(str(fa))
        
        ft = FMEFeature()
        ft.setGeometry(ploygon)
        self.pyoutput(ft)
    def close(self):
        pass
        

合并cad图层

import fme
import fmeobjects
import re

# Template Function interface:
def processFeature(feature):
    pass

# Template Class Interface:
class FeatureProcessor(object):
    def __init__(self):
        pass
    def input(self,feature):
        
        name = feature.getAttribute('fme_feature_type')
        
        match = [["高压|Kv","高压线"],["W|仓储","仓储用地"],["公路","公路"],["ROAD|RD|S1|S3|交通|路","道路"],["R|居住","居住用地"],["G2|防护绿地","防护绿地"],["M|工业","工业用地"],["G1|公共绿地","公共绿地"],["G3|S2|广场","广场用地"],["教育","教育科研用地"],["RIVER|E1|河","河流"],["B1|CR|C2|市场|商业","商业用地"],["B4","公用设施营业用地"],["A3|中小学","中小学用地"],["U|C9|公共设施|市政","市政用地"],["A2|C3|文体|文化","文化娱乐"],["C4|体育","体育用地"],["S3|停车","停车场"],["C7|文物|古迹","文物古迹"],["A1|C1|行政|办公","行政办公用地"],["A5|C5|医疗|卫生","医疗卫生用地"],["村镇|村庄","村庄"],["储备","备用地"]]
        
        
        for i in range(0,len(match)):
            
            reg = re.search(match[i][0],name)
            if(reg!=None ):
                feature.setAttribute('fme_feature_type',match[i][1])
                self.pyoutput(feature)
                break
    def close(self):
        pass

输出信息

from fmeobjects import FMELogFile

FMELogFile().logMessageString("hello world")

创建属性

import fme
import fmeobjects
from fmeobjects import FMELogFile
from fmeobjects import FMEFeature, FMEPoint, FMELine, FMEGeometryTools,FMECurve,FMEPolygon
import re


# Template Function interface:
def processFeature(feature):
    pass

# Template Class Interface:
class FeatureProcessor(object):
    def __init__(self):
        pass
    def input(self,feature):
   
        path = feature.getAttribute('autocad_xrecord_data_list{1}')
        
        path = path.replace("string:","")
        path = path.replace(".txt","")
        
        str_list = re.split(",|,",path)
        
        FMELogFile().logMessageString(str(str_list))
        try:
            feature.setAttribute('agent',str(str_list[0]))
            feature.setAttribute('landid',str(str_list[1]))
            feature.setAttribute('projname',str(str_list[2]))
        except Exception as e:
            FMELogFile().logMessageString(str(e))
        pass
        self.pyoutput(feature)
        
    def close(self):
        pass
        


读取多个cad坐标点生成红线

import fme
import fmeobjects
# Template Function interface:
# When using this function, make sure its name is set as the value of
# the 'Class or Function to Process Features' transformer parameter

from fmeobjects import FMELogFile
import re
from fmeobjects import FMEFeature, FMEPoint, FMELine, FMEGeometryTools,FMECurve,FMEPolygon

# Template Class Interface:
# When using this class, make sure its name is set as the value of
# the 'Class or Function to Process Features' transformer parameter
class FeatureProcessor(object):
    def __init__(self):
        pass
    def input(self,feature):
        #self.pyoutput(feature)
        
        List_counter = feature.getAttribute('_element_count')
        
        xs = []
        ys = []
        for i in range(int(List_counter)):
            
            text = feature.getAttribute('_list{'+str(i)+'}.autocad_text_string')
            
            if(re.search("X *=",text)!=None):
                xs.append(float(text.split("=")[1]))           
            if(re.search("Y *=",text)!=None):
                ys.append(float(text.split("=")[1]))
            
        points = []
        for i in range(0,len(xs)):
            points.append((ys[i],xs[i]))
            
        curve = FMELine(points)
        ploygon = FMEPolygon(curve)
        
        FMELogFile().logMessageString(str(xs))
         
        ft = FMEFeature()
        ft.setGeometry(ploygon)
        ft.setAttribute('path',str(feature.getAttribute('autocad_source_filename')))
        self.pyoutput(ft)
             
    def close(self):
        pass

在这里插入图片描述

提取红线

提取条件:红色,宽度大于0,有坐标点。
障碍:红线并不完全闭合,其他红线的干扰
解决思路:特征筛选,坐标点在面上最多的面判定为目标红线

在这里插入图片描述
在这里插入图片描述

通过WorkplaceRunner 一个一个文件进行处理
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
FME CAD转GDB是指在FME软件中将CAD(计算机辅助设计)文件格式转换为GDB(地理数据库)文件格式。 首先,FME软件是一种强大的数据转换和集成工具,可以处理各种不同的数据格式。CAD文件是一种常见的设计文件格式,用于创建和编辑图形和设计元素。而GDB文件是一种用于存储地理数据的文件格式,通常由地理信息系统(GIS)软件使用。 在FME中进行CAD转GDB的过程包含以下几个步骤: 1. 导入CAD文件:通过FME中的CAD阅读器,将CAD文件导入到FME的工作空间中。 2. 数据转换:使用FME中的转换器和处理器,将CAD数据转换为GDB数据模型。这可能涉及到属性映射、几何转换以及数据清洗等操作,以确保数据的准确性和一致性。 3. 转换参数设置:根据需要,可以通过FME的参数设置来调整转换过程中的各种参数,如坐标系统转换、属性规则、拓扑检查等。 4. 导出GDB文件:使用FME的GDB写入器,将转换后的数据保存为GDB文件格式。在此过程中,可以选择性地创建数据集、要素类和属性表等。 通过FME进行CAD转GDB的优势在于它的灵活性和功能强大性。FME提供了丰富的数据转换和处理功能,可以处理大量的数据和各种数据格式。此外,FME还支持自动化工作流和批量处理,使得大规模数据转换变得更加高效和便捷。 总之,使用FME软件进行CAD转GDB可以帮助用户将CAD文件转换为与GIS软件兼容的GDB文件,以便在地理信息系统中进行分析、查询和可视化等操作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值