Hi all,
I did look through the samples and the API doco but I couldn’t find anything where someone has used MILSTD 2525 symbology for points on a layer. I’m guessing I can just use a custom style to render each point, but was hoping it was either a default style or someone already had a style (including the required bitmaps/graphical symbols) for it.
Can anyone help me out?
MILSTD 2525 symbology
Hi Scott,
I guess you means the symbols mentioned at en.wikipedia.org/wiki/NATO_Military_Symbols_for_Land_Based_Systems . In that case, I think it’s not complicated to support it by creating a customized point style inherited from PointShape, in which, you can overwrite the DrawCore method, for example, if we would like to draw a symbol like the following:
we can use the code as below to draw it in DrawCore method of customized point style:
private
void
Draw61(Feature feature, GeoCanvas canvas, GeoPen geoPen, GeoBrush geoBrush)
{
string
[] paths =
new
string
[] {
“27.5,10 21.3333,9.91667 18.8338,8.99602 16.9176,7.90838 15.584,7.23862 14.5011,6.31816 13.3345,7.32254 12.3349,8.5776 11.3354,10.3347 10.0859,12.3433 9.00308,14.4357 8.00325,16.36 7.50333,17.8666 7.00341,19.708 6.33685,22.2181 5.75396,25.1466 5.50401,27.5737 5.50401,30.5862 5.75396,33.5151 6.42051,36.7783 7.33701,40.2088 8.33683,42.6359 9.75324,45.23 11.4196,48.0755 12.9193,50.4182 15.0023,53.1797 17.3352,56.0248 19.6681,58.1172 21.5844,59.6231 23.6674,60.878 25.667,61.9655 27.5833,62.886 30.4165,64.1409 32.5824,65.061 33.8325,65.396 35.3326,65.312 37.8326,64.6426 40.0826,63.3037 42.6659,61.7975 45.8318,59.7055 48.3318,57.8646 50.4985,55.7726 53.0815,53.2623 55.2483,50.8356 57.498,47.5721 59.2478,43.8902 61.0809,39.79 61.5812,38.6185 62.2481,35.0203 62.748,29.9159 62.498,25.3972 61.9148,22.2175 61.1648,19.1213 59.8316,15.9415 58.1652,12.176 56.9153,10.5861 55.8321,8.82886 54.9155,7.32264 53.749,6.31849 51.4992,8.41046 49.2494,9.49829 48.1662,9.91668 41.0836,10.084 39.4171,9.16357 37.584,8.32678 35.9175,7.57368 34.1677,6.31849 32.0012,7.65735 30.2514,8.57782 27.7517,9.91668 27.5,10”
,
“7.75,17.25 59.9167,17.0833”
};
for
(
int
i = 0; i < paths.Length; i++)
{
Collection<PointF> points =
new
Collection<PointF>();
foreach
(
string
pointStr
in
paths<i>.Split(
’ ‘
))
{
string
[] coordinates = pointStr.Split(
’,’
);
float
x = Convert.ToSingle(coordinates[0], CultureInfo.InvariantCulture);
float
y = Convert.ToSingle(coordinates[1], CultureInfo.InvariantCulture);
points.Add(
new
PointF(x, y));
}
DrawLineWithPoints(feature, canvas, geoPen, points.ToArray());
}
}
The coordinates of the path is a relative path from a demo image, maybe it’s a coordinate for drawing it in SVG etc. In the DrawLineWithPoints method, we will do a coordinate conversion from demo image to canvas image, just show the code as following:
private void DrawLineWithPoints(Feature feature, GeoCanvas canvas, GeoPen geoPen, PointF[] points)
{
PointShape centerPoint = feature.GetShape().GetCenterPoint();
ScreenPointF centerPointInScreen = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, centerPoint.X, centerPoint.Y, canvas.Width, canvas.Height);
float scaleRatio = SymbolSize / sampleIconSize;
float halfSampleIconSize = sampleIconSize * 0.5f;
if (points != null && points.Length > 0)
{
PointF[] drawingPoints = new PointF[points.Length];
for (int i = 0; i < points.Length; i++)
{
drawingPoints<i> = new PointF((float)centerPointInScreen.X - (halfSampleIconSize - points<i>.X) * scaleRatio, (float)centerPointInScreen.Y - (halfSampleIconSize - points<i>.Y) * scaleRatio);
}
Vertex[] worldPointShapes = new Vertex[points.Length];
for (int i = 0; i < drawingPoints.Length; i++)
{
PointShape worldPoint = ExtentHelper.ToWorldCoordinate(canvas.CurrentWorldExtent, drawingPoints<i>.X, drawingPoints<i>.Y, canvas.Width, canvas.Height);
worldPointShapes<i> = new Vertex(worldPoint.X, worldPoint.Y);
}
LineShape lineShape = new LineShape(worldPointShapes);
canvas.DrawLine(lineShape, geoPen, Core.DrawingLevel.LabelLevel);
}
}
Thanks,
Johnny