Learning building applications with FME objects 3 operating elements (features)

Source: Internet
Author: User

Fmeofeature is a feature object and is an FME object application.ProgramIn general, the element is a set of attributes and a ry associated with the coordinate system. When an application reads data from a dataset, it reads the element data one by one, when an application writes data to a dataset, the elements can be operated by all standard FME functions and processors. The following is the Logical Data Model of the elements:

 

The above figure shows the logic model. FME objects does not provide one-to-one APIs for these classes, and all data is accessed through the fmeofeature object.

 

The following sections describe the relationship between logical classes and attributes. Note that class: attribute is the attribute of the referenced class.

 

The input element type is stored in the feature: featuretype attribute.

 

Element attributes are grouped by the following types:

    • Format attribute
    • User attributes
    • FME attributes

 

One element can have no or multiple format attributes, and one formatattribute is a specific format attribute, such as autocad_block_name and sde30_justification.

 

One element can have no or multiple user attributes. The user attributes are custom attributes, such as parcel_identifier, owner_name, and data_surveyed.

 

FME attribute name prefix FME _. Overwrite format attributes with FME attributes. For example, fme_color and fme_fill_color attribute can represent the Element Strength. (For details, see the FME architecture chapter in the FME Foundation manual ).

 

More importantly, feature: fme_type and geometry: fme_geometry. Geometry class indicates the element location information. The element ry can be a point, line, or no. A element contains multiple set graphs, which are called aggregate (aggregate) ry. The element can also have no ry.

 

Important differences between fme_type and fme_geometry:

Fme_geometry represents the geometric type of the actual coordinates.

Fme_type specifies how to display ry.

For example, a point can be expressed as multiple FME types: Point, arc, ellipse, and TXT.

The correspondence between fme_type and fme_geometry is as follows:

 

If you want to create an application with a neutral format, you must use only the FME attribute processing elements. If you do not want to use special format attributes, it is easy to work in your application.

 

Each ry is associated with only one coordinate system. For more information, see the working with Coordinate Systems page 55th.

 

The fmeofeature method and attribute icons are shown below:

The following content will be learned:

    • Operation element attributes
    • Interpretation element ry
    • Schema for a feature)

For the relationship between elements and coordinate systems, see Chapter 7th working with coordinate systems in this tutorial.

In chapter 1 of this tutorial, advanced feature processing includes the element processing methods, such as descrimfuntion and processfeatures, and how to apply factory pipelines to elements.

 

Note: All examplesCodeIt only works in 2D ry. If you need to process 3D ry, You need to extend the sample code.

 

Operation element attributes

The following table lists the attributes and methods that can be used to operate on format attributes, user attributes, and FME attributes:

Attribute or Method Description
Allattributenames This method returns all attributes of a element, including the format, user, and FME attributes.
Attribute This attribute is used to obtain or set string attributes.
Attributeexists This method is used to determine whether a property exists. If a property exists, fme_true is returned. If no property exists, fme_false is returned.
Booleanattribute This attribute is used to obtain or set a Boolean attribute.
Int16attribute This attribute is used to obtain or set the 2-byte integer attribute.
Int32attribute This attribute is used to obtain or set the 4-byte integer attribute.
Real32attribute This attribute is used to obtain or set the 4-byte integer attribute.
Real64attribute This attribute is used to obtain or set the 8-byte integer attribute.
Cloneattributes This method copies the element types and all attributes of the source element to the target element. The target element does not have the source element type and attribute.
Note: This method does not copy the Source Element's ry to the target element. If you need to copy the ry, you can use the clone method.
Clone This method copies the element types, all attributes, and ry of the source element to the target element. The target element does not have the source element type and attribute.

 

In the getfeatureattributes process, the getallattributenames method is used to obtain all the attributes of the input element and put the results into two collections. One of them is placed with the attribute name and the other with the attribute value.

 

Sub getfeatureattributes (byval fmefeature as fmeofeature ,_
Byval colnamelist as collection ,_
Byval colvaluelist as collection)
Dim fmeattributenames as fmeostringarray
Dim sname as string
Dim svalue as string
Dim lentries as integer
Dim I as integer
Dim D as double
Dim B as Boolean
Set fmeattributenames = m_fmesession.createstringarray
Call fmefeature. allattributenames (fmeattributenames)
Lentries = fmeattributenames. Entries
For I = 0 to lentries-1
Sname = fmeattributenames. element (I)
Svalue = fmefeature. Attribute (sname)
Call colnamelist. Add (sname)
Call colvaluelist. Add (svalue)
Next I
End sub

Use attribute to set attributes and use attributeexists to query whether the attribute exists. If the attribute exists, write changed_value. If the attribute does not exist, create a new attribute and write it to new_value.

If fmefeature. attributeexists ("my_attribute") then
Fmefeature. Attribute ("my_attribute") = "changed_value"
Else
Fmefeature. Attribute ("my_attribute") = "new_value"
Endif

 

Any element attribute can be obtained using the attribute of the fmeofeature object, because the FME object will automatically perform type conversion, and the automatic type conversion should be used with caution to avoid undefined results. Effective conversion of the lower Table type. cells not empty in the table represent undefined results.

The cloneattributes method can be used to copy the attribute of the source element to the target element. The Code is as follows:

Dim fmetargetfeature as fmeofeature
Set fmetargetfeature = m_fmesession.createfeature
Fmesourcefeature. cloneattributes (fmetargetfeature)

Tip: Any attribute with the same name in the target element will be overwritten by the source element attribute.

 

 

References:

Building applications with FME objects February 2005

Reprinted please noteArticleSource http://www.cnblogs.com/booolee

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.