Class TLcdISO19103MeasureAnnotation
- All Implemented Interfaces:
ILcdAnnotation
ILcdAnnotation
that associates a certain unit of measure with a type or property.
A typical use-case of this annotation is if the decoded model just contains number values for a certain
property, but you have extra knowledge to associate a unit of measure to that number.
By adding the association, you expose this information to other parties.
For example, a UI can show the unit next to the number which gives meaning to the number for the UI user.
Another example is that it allows to compare values from different models even
if they use a different unit by converting them to a common unit.
Note that this is only possible if the unit of measure applies to all possible
values of the type or property. In case the unit of measure can vary, the
ILcdISO19103Measure
interface should be implemented by the model class representing
that specific type.
Example
For example consider a SHP file containing street data where one of the property fields represent the maximum allowed driving speed on that road expressed in km/h:
TLcdDataModel dataModel = ...;
TLcdDataType streetDataType = ...;
//annotate the field with a UOM, indicating that the field represents a speed
TLcdDataProperty maxSpeedProperty = streetDataType.getProperty("MaxSpeed");
buildingDateProperty.addAnnotation(new TLcdISO19103MeasureAnnotation(TLcdUnitOfMeasureFactory.SPEED_KILOMETRE_HOUR));
Alternative
If the model decoder knows which properties represent unit of measures, an alternative to using this annotation is storingILcdISO19103Measure
instances directly in the data model:
TLcdDataModelBuilder builder = new TLcdDataModelBuilder("http://www.mydomain.com/datamodel/myDataModel");
TLcdDataTypeBuilder speedMeasure = builder.typeBuilder("MaxSpeed").instanceClass(ILcdISO19103Measure.class);
TLcdDataTypeBuilder dataType = builder.typeBuilder("RoadType");
dataType.addProperty("MaxSpeed", speedMeasure).
...
//In this example, the model decoder would store ILcdISO19103Measure instances in the data model:
ILcdDataObject domainObject = ...;
domainObject.setValue("MaxSpeed", new TLcdISO19103Measure(25, TLcdUnitOfMeasureFactory.SPEED_KILOMETRE_HOUR));
- Since:
- 10.0
-
Constructor Summary
ConstructorDescriptionTLcdISO19103MeasureAnnotation
(ILcdISO19103UnitOfMeasure aUnitOfMeasure) Constructs an annotation with the given unit of measure. -
Method Summary
Modifier and TypeMethodDescriptionReturns the unit of measure for the annotated property or type.
-
Constructor Details
-
TLcdISO19103MeasureAnnotation
Constructs an annotation with the given unit of measure.- Parameters:
aUnitOfMeasure
- the unit of measure for this annotation
-
-
Method Details
-
getUnitOfMeasure
Returns the unit of measure for the annotated property or type.- Returns:
- the unit of measure for this property or type
-