Visualizing Military Symbology data on a map requires two steps:
-
Create an
IFeatureModel
IFeatureModel
IFeatureModel
containing the data. The model is created and not decoded from disk, because the military symbology standard does not describe a file format. -
Create a
FeatureLayer
FeatureLayer
FeatureLayer
for the model and add it to theMap
Map
Map
.
// Create the coordinate reference in which the model will be defined.
auto crs = TestCrs::epsg4326();
// Create an APP-6 symbol "unmanned aerial vehicle unit" and set a value for its text modifier "Unique Designation".
auto symbol = MilitarySymbol::create(MilitarySymbology::Standard::App6d, "10060100001103000000");
symbol->putValue(MilitarySymbol::Modifier::UniqueDesignation, "Regular");
// Copy the symbol to a Feature instance and a point geometry.
Feature emptyFeature = Feature::newBuilder().dataType(MilitaryDataModel::getSymbolType()).build();
auto featureGeometry = GeometryFactory::createPoint(crs, 0, 27, 46);
auto feature = symbol->copyToFeature(emptyFeature, featureGeometry);
// Declare the model metadata.
auto modelMetadata = ModelMetadata::newBuilder().title("My Symbology Model").build();
auto featureModelMetadata = FeatureModelMetadata::newBuilder().dataModel(MilitaryDataModel::get()).reference(crs).build();
auto modelBounds = GeometryFactory::createBounds(crs, featureGeometry->getLocation(), 0, 0, 0);
// Build an IFeatureModel containing only the feature we just created.
auto militarySymbologyModel = FeatureModelBuilder::newBuilder()
.modelMetadata(modelMetadata)
.featureModelMetadata(featureModelMetadata)
.bounds(modelBounds)
.features({feature})
.build();
// Finally, put the model in a layer, and add it to the map.
// A default IFeaturePainter is automatically deduced from the model's data model.
auto layer = FeatureLayer::newBuilder().model(militarySymbologyModel).build();
map->getLayerList()->add(layer);
// Create the coordinate reference in which the model will be defined.
var crs = CoordinateReferenceProvider.Create("EPSG:4326");
// Create an APP-6 symbol "unmanned aerial vehicle unit" and set a value for its text modifier "Unique Designation".
var symbol = MilitarySymbol.Create(MilitarySymbology.Standard.App6d, "10060100001103000000");
symbol.PutValue(MilitarySymbol.Modifier.UniqueDesignation, "Regular");
// Copy the symbol to a Feature instance and a point geometry.T
Feature emptyFeature = Feature.NewBuilder().DataType(MilitaryDataModel.SymbolType).Build();
var featureGeometry = GeometryFactory.CreatePoint(crs, 0, 27, 46);
var feature = symbol.CopyToFeature(emptyFeature, featureGeometry);
// Declare the model metadata.
var modelMetadata = ModelMetadata.NewBuilder().Title("My Symbology Model").Build();
var featureModelMetadata = FeatureModelMetadata.NewBuilder().DataModel(MilitaryDataModel.Get()).Reference(crs).Build();
var modelBounds = GeometryFactory.CreateBounds(crs, featureGeometry.Location, 0, 0, 0);
// Build an IFeatureModel containing only the feature we just created.
var militarySymbologyModel = FeatureModelBuilder.NewBuilder()
.ModelMetadata(modelMetadata)
.FeatureModelMetadata(featureModelMetadata)
.Bounds(modelBounds)
.Features(new List<Feature> { feature })
.Build();
// Finally, put the model in a layer, and add it to the map.
// A default IFeaturePainter is automatically deduced from the model's data model.
var layer = FeatureLayer.NewBuilder().Model(militarySymbologyModel).Build();
map.LayerList.Add(layer);
// Create the coordinate reference in which the model will be defined.
CoordinateReference crs = CoordinateReferenceProvider.create("EPSG:4326");
// Create an APP-6 symbol "unmanned aerial vehicle unit" and set a value for its text modifier "Unique Designation".
MilitarySymbol symbol = MilitarySymbol.create(MilitarySymbology.Standard.App6d, "10060100001103000000");
symbol.putValue(MilitarySymbol.Modifier.UniqueDesignation, "Regular");
// Copy the symbol to a Feature instance and a point geometry.
Feature emptyFeature = Feature.newBuilder().dataType(MilitaryDataModel.getSymbolType()).build();
Point featureGeometry = GeometryFactory.createPoint(crs, 0, 27, 46);
Feature feature = symbol.copyToFeature(emptyFeature, featureGeometry);
// Declare the model metadata.
ModelMetadata modelMetadata = ModelMetadata.newBuilder().title("My Symbology Model").build();
FeatureModelMetadata featureModelMetadata = FeatureModelMetadata.newBuilder().dataModel(MilitaryDataModel.get()).reference(crs).build();
Bounds modelBounds = GeometryFactory.createBounds(crs, featureGeometry.getLocation(), 0, 0, 0);
// Build an IFeatureModel containing only the feature we just created.
IFeatureModel militarySymbologyModel = FeatureModelBuilder.newBuilder()
.modelMetadata(modelMetadata)
.featureModelMetadata(featureModelMetadata)
.bounds(modelBounds)
.features(Collections.singletonList(feature))
.build();
// Finally, put the model in a layer, and add it to the map.
// A default IFeaturePainter is automatically deduced from the model's data model.
FeatureLayer layer = FeatureLayer.newBuilder().model(militarySymbologyModel).build();
map.getLayerList().add(layer);
See this article if you want to customize the styling of your military symbols.