顾OpenStreetMap (OSM) XML用户配置文件idelines

The OSM configuration file is a simple XML document that users can write to modify the map features and attributes that FME recognizes.The syntax is divided into two simple functions: adding/modifying map features, attributes, and geometry types;and removing them.

All the remaining content of the config should be contained within a root element.You can find an example of a configuration file by looking at FME’s config file at \xml\osm\fme_map_features.xml .This file adds all the OSM wiki defined map features to FME.It is strongly recommended that you do not edit this file and instead specify any changes you wish to make in your own config file.

Adding Map Features

The primary method of adding map features is by writing elements that contain child elements.For example:

           
           
           
           

          

This adds the broad featureaerialwaywith specific featuresaerialway_cable_car,aerialway_gondola, andaerialway_chair_lift.In this case, writing this in your user config would be unnecessary because aerialway is an OSM-wiki-defined feature and is already understood by FME.

The Add Command

An add command can be specified by adding children elements to an element.These children elements include , , , and .

An alternative way to add map features is by specifying the key and value in an element.For example:

           
           
           
           

          

This is equivalent to the code found above, in theAdding Map Featuressection.Note that the attributevin the element is optional.

The method of adding attributes and geometry types are almost identical via add commands.Both and elements havename,k, andvattributes.Only thenameattribute is mandatory;thekattribute is only necessary whenvis specified.For example:

           
           
           
           
           
           
           
            
           
           

          

This addsattr1andarea(xml_area) to ALL existing map features and also any map features that are created in the future.attr2andline(xml_line) are added to theshopfeature and also all of its specific features.Any specific features that are added toshopin the future will also haveattr2line(xml_line).attr3andpoint(xml_point) are added to ONLY theshop_carfeature.attr4has specified a value but notkey, soattr4will not be added to anything.

Note that the geometry types in the config file are generic so that the file can be shared with OSM PBF.These generic names will map to XML types on the actual feature for OSM XML.

The following is a list of the supported geometry types with their xml type mappings that you can specify in your config file:

aggregate -> xml_aggregate
no_geom -> xml_no_geom
area -> xml_area
line -> xml_line
point -> xml_point

You should only be specifying these values in thenameattribute of the element.

The attribute element also has an additional, optionaltypetag that can be used to add types to new attributes or modify the type of attributes on existing features.Note that the type names in the config file are also generic.These generic names will map to XML types on the actual feature for OSM XML.For example:

           
           

          

Ifshop_caralready has an attribute calledattr_with_type, its type will be changed todatetime(xml_datetime).Otherwise, an attribute calledattr_with_typewith typedatetime(xml_datetime) will be added to it.Either way, the result ends up being the same.Note that if the type isn’t specified in the attribute element, the type will be defaulted tostring(xml_buffer).The following is a list of the supported attribute types (with their xml type mappings) that you can specify in your config file:

string -> xml_buffer
int32 -> xml_int32
int64 -> xml_int64
double -> xml_real64
datetime -> xml_datetime

Lastly, the tag can be used to determine whether the geometry of a closed way feature should be interpreted as a line or an area.An example of how to use the linear option can be found in the fme map features config file at \xml\osm\fme_map_features.xml :

           
           
           

          

For the tag, it is mandatory to specify at least a k attribute while v is optional.By default, all closed way features, including any new user defined feature types, will be interpreted as areas.Exceptions to this are the barrier and highway feature types and their related types (that is,highway_motorway,barrier_block).

Anareatag in an OSM element will override the default interpretation of a closed way feature.If theareatag is set toyes, closed way features will always be interpreted as an area.Whereas if theareatag is set tono, it will always be interpreted as a line.More information on this can be found athttp://wiki.openstreetmap.org/wiki/Key:area.

The Remove Command

The syntax and logic forremoving , , , and elements are extremely similar to the syntax and logic foradding, except that they take place as children of a tag instead.There are two key things to be aware of:

  1. Specifyingremoveon an with only akattribute won’t just remove the broad feature – it will also remove all of its specific features.For example:
           
           

          

This doesn’t just remove the barrier feature;it also removesbarrier_block,barrier_wall, etc.

  1. Note that the element here does not accept a type attribute.

Ordering of Commands

The order in which map features are added and removed does matter – features that were previously added can be removed, and vice versa.This also applies to attributes and geometry types, which can be especially useful in certain cases.For example, imagine the broad featureshopand all of its specific features have the attributewidth.Suppose you only want the attribute width to be on the featureshop_car.用户配置可以包括下列this:

           
           

          
           

          
           

          

However, the way attributes and geometry types are applied to map features is not affected by order.This means that attributes and geometry types can be added to features that have not yet been defined.For example, compare the following two config files:

1.

           
           
           
           
           
           
           

          

2.

           
           
           
           
           
           
           

          

These files perform the exact same function.Map featurespark,park_tree,desert,desert_cactus, anddesert_sandare added:

  • parkandpark_treewill haveglobal_attr
  • desert,desert_cactus, anddesert_sandwill havek_attr
  • desert_sandwill havev_attr

Default Attributes and Geometry Types

Specified in FME’s config file (found at at \xml\osm\fme_map_features.xml ), are several attributes and geometry types that will be added by default to any new map features unless specified otherwise.Once again, it is strong advised that any changes you wish to make should be done in your own config file and NOT infme_map_features.xml.The default attributes all have typestring(xml_buffer).They include:

id
timestamp
user
created_by
visible
area
layer
uid
version
changeset
tag{}.k
tag{}.v
nd{}.ref
member{}.type
member{}.ref
member{}.role
osm_feature_type
osm_theme

The default geometry types are:

aggregate (xml_aggregate)
no_geom (xml_no_geom)
area (xml_area)
line (xml_line)
point (xml_point)