You can use the SpawnObjectMapping type mapping file to allow mapping to be done using an external language such as XSL or Python. Only GO to GO mapping is supported.
The SpawnObjectMapping type mapping file can be used with any application that currently supports other mapping file types. It will also be available to be called inside the Object Mapping File Sequence To Execute type mapping file, in the same way as other mapping files.
When using the SpawnObjectMapping type mapping file, the application will create an input XML with the same syntax that is created with XSL-type portrayals. The input XML will have the format indicated by, and include only, objects specified by the Objects section of the mapping file.
The input XML will be given to the external transformation process (XSL, PY, EXE, etc.) to create an output XML file.
The output XML file is expected to use a specific format. It will be used to create the new features in the same way that new features are mapped using any other mapping files. Schema validation is applied when processing the created output XML file. The spatial of the input feature, as denoted by the id tag on the NewObject entries, will be used to create the new spatial for the new feature. If there is a Message tag, an output message will be created in the same way that the OutputMessage tag is used in the original object mapping table.
Messages logged to the Output window will be consistent with any other mapping. They will list the number of features mapped as well as any errors, warnings or output messages.
SpawnObjectMapping has the following attributes.
Tag | Attribute | Status |
|---|---|---|
Processor | The Processor tag gives the file to use to transform the input XML file to the output XML file. This file can be a .PY or .EXE file, as long as it creates the output XML file as expected. Relative and absolute file paths are supported. | Mandatory |
InputFile | The InputFile tag is optional for XSL-type transformations but is useful to make the input XML file persistent for debugging purposes. The parameter useLayerName prefixes the filename with the layer name and an underscore. The file will be created in the Temporary Files folder as specified in Tools > Options > Files and Folders.
| Optional |
OutputFile | The OutputFile tag is optional for XSL- type transformations but is useful to make the input XML file persistent for debugging purposes. The parameter useLayerName prefixes the filename with the layer name and an underscore. The file will be created in the Temporary Files folder as specified in Tools > Options > Files and Folders. The OutputFile name must not be the same name as the InputFile.
There will be one or more MapObject entries for each new object that is to be created. A DoNotMapObject element can be used to indicate that an object is being intentionally skipped from being mapped. The MapObject and DoNotMapObject elements include the id attribute, which references the input feature (from the input XML). A NewObject child is required for each MapObject entry. There must be one and only one NewObject child per MapObject entry. The NewObject child will define the object acronym, (optional) index, (optional) foid, (optional) attributes and (optional) contributing input features that were used to create the new object. The index value is optional. It defines a one-based index indicating the index of the output feature that is being created. • If mapping one:one or many:one, the index value is optional (the index is assumed to be 1 if not given). • If mapping one:many, the index must be incremented for each new object that is created from the same source object. Note that if mapping many:one, the id attribute references the first source object that is mapped. Subsequent objects that are mapped to an already mapped object will update the same NewObject element and add an Input element indicating the input feature that contributed to the mapping of the new objects. The Input element is optional if the NewObject was created by only one input feature, because the id attribute will indicate the main input feature. If the geometry is to be converted, the (optional) convertGeometry attribute can be used. The Message child is optional. If given, an output message will be issued in the same manner as the use of OutputMessage tag in the object-to-object XML mapping files. | Optional |
Objects | The Objects tag is mandatory and is used to define the objects to process through the transformation. The attributes are consistent with those used with XSL portrayal and will be used when creating the input XML file. The includeAllSpatialReferences attribute indicates if spatial references for all features are to be included in the input XML file. The compositionInline attribute indicates if the object composition should be inline in the input XML file. The includeAssociations attribute indicates if associations should be included in the input XML file. It is not yet fully supported.
There will be a child Object tag for each object to be included in the input XML file. The following applies: • The includeSpatialReferences attribute is optional. If set to TRUE, spatial references will be included for the features matching this Object entry. • The includeAssociations attribute is optional. If set to TRUE, associates should be included for the features matching this Object entry. This attribute is not yet fully supported. • Each Object tag may have a child Filter tag to filter which objects with this acronym to include. All filters that are available through the ObjectToObjectConversionTable type mapping files will also be supported here. | Mandatory |
In this example, a sample mapping file using the SpawnObjectMapping type is shown.
<?xml version="1.0" encoding="UTF-8"?> <SpawnObjectMapping Version="1.0" FromType="GO" ToType="GO"> <Processor>transform.xsl</Processor> <InputFile useLayerName="true">inputFilename.xml</InputFile> <OutputFile useLayerName="true">outputFilename.xml</OutputFile> <Objects includeAllSpatialReferences="false" compositionInline="true" includeAssociations="false"> <Object Acronym="ADMARE"> <Filter> <AttributeValueIsLike Acronym="INFORM" Value="(Marine pollution regulations area)" MatchCase="False"/> </Filter> </Object> <Object Acronym="BRIDGE"> <Filter> <GeometryIsWithin> <Filter> <ObjectAcronymIsEqualTo Acronym="LNDARE"/> </Filter> </GeometryIsWithin> </Filter> </Object> <Object Acronym="TOPMAR" includeSpatialReferences="true"> <Filter> <ObjectIsAChildTo Acronym="BCNLAT"/> </Filter> </Object> <Object Acronym="LNDMRK" includeSpatialReferences="true" includeAssociations="true"/> </Objects> </SpawnObjectMapping> |
In this example, a sample input XML file is shown.
<?xml version="1.0" encoding="UTF-8"?> <!-- This XML file includes a list of all objects being processed. It uses the same format as the input XML that is used by our XSL portrayal. --> <Dataset> <Points> <Point xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="p1"/> <Point xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="p2"/> <Point xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="p3"/> <Point xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="p4"/> </Points> <Curves> <Curve xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="c1"> <Boundary ref="p4" boundaryType="Begin"/> <Boundary ref="p4" boundaryType="End"/> </Curve> </Curves> <Surfaces> <Surface id="s1"> <Ring type="Outer"> <Curve ref="c1" orientation="Reverse"/> </Ring> </Surface> </Surfaces> <Features> <LIGHTS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="f0" foid="1C 0000000054 00001" primitive="Point"> <CATLIT> <Value>6</Value> </CATLIT> <HEIGHT>1</HEIGHT> <Point ref="p1"/> </LIGHTS> </Features> </Dataset> |
In this example, a sample output file is shown.
<?xml version="1.0" encoding="UTF-8"?> <MappingOutput xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.caris.com/schema/mappingOutput/0.1">
<!-- Example of many:one mapping. A single MapObject entry will be created with a NewObject element. The id attribute will reference the input feature that was used to create the new object. The Input element will indicate which input features contributed to the new object. The replace attribute on the Input element will indicate if the input feature was consumed or merged into the new one (i.e., replaces the input feature). replace="false" means that the input feature contributed to the output feature but there may still be another mapping that replaces the input feature with another object. --> <MapObject id="f0"> <NewObject foid="1C 0000000053 00001"> <LightAirObstruction> <height>1</height> <featureName> <name>test1</name> </featureName> </LightAirObstruction> <Input id="f0" replace="true"/> <Input id="f1" replace="false"/> </NewObject> <Message>LightAirObstruction made from 2 LIGHTS</Message> </MapObject>
<!-- Example of one:one mapping --> <MapObject id="f2"> <NewObject foid="1C 0000000055 00001"> <LightAirObstruction> <height>1</height> <featureName> <name>test2</name> </featureName> </LightAirObstruction> </NewObject> <Message>LightAirObstruction made from 1 LIGHTS</Message> </MapObject>
<!-- Example of one:many mapping - simply include multiple MapObject entries with the same input feature. The index value must be used and incremented for each NewObject entry. --> <MapObject id="f3"> <!-- No foid attribute indicates that a new foid is to be generated. --> <NewObject index="2"> <LightFogDetector> <featureName> <name>test3b</name> </featureName> </LightFogDetector> </NewObject> <Message>LightFogDetector made from 1 LIGHTS.</Message> </MapObject>
<!-- Example of mapping and converting geometry --> <!-- To be consistent with the mapping convertGeometry procedure, the convertGeometry tag can be one of: Area, Line, Point, Sounding or Text --> <!-- The same geometry conversions will be supported as are supported by the mapping convertGeometry procedure. --> <MapObject id="f4"> <NewObject foid="1C 0000000472 00005" convertGeometry="Point"> <Berth> <height>1</height> <featureName> <name>test4</name> </featureName> </Berth> </NewObject> <Message>Berth made from 1 BERTHS. Converted to a point.</Message> </MapObject>
<!-- Example for creating collections --> <!-- The Collection tag indicates that this new object will be added to a collection with the given feature code and attributes. The Collection tag can be repeated if the new feature is to be a part of multiple collections. Duplicate collections will not be created. All new objects that reference a collection with the same feature code and attributes will be added to the same collection. --> <MapObject id="f6"> <NewObject> <Berth> <featureName> <name>test6a</name> </featureName> </Berth> </NewObject> <Collection> <MooringTrot> <featureName> <name>test6b</name> </featureName> </MooringTrot> <AssociationType> <MooringTrotAggregation/> </AssociationType> </Collection> </MapObject>
<!-- Example for creating information objects --> <!-- The Information tag indicates that this new object will be linked to an information object with the given feature code and attributes. It has an (optional) spatialIndex attribute that must be used if the information object references spatial(s) instead of the entire feature. The spatialIndex attribute is a one-based index indicating which simple spatial (curve for lines/areas or point for points/soundings) it applies to. The spatialIndex attribute can be repeated if the same information object applies to multiple spatials. The Information tag can be repeated if the new feature (or any of its spatials) is to be linked to multiple information objects. Duplicate information objects will not be created. All new objects that reference a information object with the same feature code and attributes will be added to the same information objects. --> <MapObject id="f7"> <NewObject> <Berth> <featureName> <name>test7a</name> </featureName> </Berth> </NewObject> <Information> <NauticalInformation> <featureName> <name>test7b</name> </featureName> </NauticalInformation> <AssociationType> <AdditionalInformation/> </AssociationType> </Information> <Information spatialIndex="1"> <SpatialQuality> <horizontalPositionUncertainty> <uncertaintyFixed>2.5</uncertaintyFixed> </horizontalPositionUncertainty> <qualityOfHorizontalMeasurement>4</qualityOfHorizontalMeasurement> </SpatialQuality> </Information> </MapObject>
<!-- Example for adding feature associations --> <!-- The AddAssociation tag indicates that this new object will be linked to another geographic object with the given association type, role and (optional) association attributes. Note that we do not yet support association attributes. This tag also includes the information for the geographic object it is being associated to.--> <MapObject id="f8"> <NewObject> <Daymark> <colour>3</colour> </Daymark> </NewObject> <AddAssociation> <AssociationType> <StructureEquipment> <!-- StructureEquipment association does not actually have any attributes but this is included to show how the attributes would be defined. --> <attribute1>test value</attribute1> </StructureEquipment> </AssociationType> <AssociationRole>supports</AssociationRole> <!-- The AssociatedRef tag references the feature that is being added as an association. The id attribute references the source feature ID from the input XML. The index attribute is optional. It will define a one-based index indicating the index of the output feature that is being added as an association. If omitted, an index of 1 is assumed. --> <AssociationRef id="f3" index="2"/> </AddAssociation> </MapObject>
<!-- Example of a DoNotMapObject entry. This is used to indicate that a feature is intentionally skipped so that the mapping tool does not report an error for a feature that had no mapping. The id attribute is mandatory, referencing the input feature (from the input XML). Message element(s) are optional and can be used if desired to include additional information to the user. --> <DoNotMapObject id="f8"> <Message>oldobject was not mapped because it is no longer needed.</Message> </DoNotMapObject>
</MappingOutput> |