When rendering multipoint with DRAW_CATEGORY_ROUTE, width not calculating correctly
I'm trying to draw a multipoint symbol and set the width using the final point, but that value is not getting calculated properly. We are using the following symbol code on 2525C:
String symbol = "GHGPOLAGM-****X"; ("Axis of Advance Ground Main Attack")
Since this symbol uses DRAW_CATEGORY_ROUTE, I set the final point at a distance for the width -- namely 5,000 meters. (Buffer point Lat: 40.76275683368822 Buffer point Lon: -122.51139636507355, Point1 Lat: 40.785026699901536 Point1 Lon: -122.56287072130478).
However, the closest I can get the rendering to my desired width (testing all 0 to 360 whole-number angles) is about 4,989 or 5,013, which is at 74 and 75 degrees. However, that margin of error is not consistent as I change the distance of the point -- at an expected 7,000 meters, our lines are 6,917 meters apart.
Additionally, the angles that work best for me seem to be 74/75, 104/105, 254/255, 284/285. In mil-sym-js, we use 45 degrees, but that renders the lines at 3,762.50733.... meters apart on mil-sym-java.
The arrow can also draw strangely at different angles and distances. This is at 5,000 meters and 45-degree angle from the line (which is originally near 0 degrees from north):

Which renderer functions are you using for mil-sym-java & mil-sym-js when you create the symbol?
Thanks for the quick response! Here's what I've got:
SECRenderer renderer = SECRenderer.getInstance(); String json = renderer.RenderMultiPointSymbol(...);
Some of my variables: bbox="" modifiers="" altitudeMode="clampToGround" scale=1.0 format=1 symStd=1
Well that scale value isn't helping. That's supposed to be the map scale, not a value that scales the size of the symbology or something. Try setting the scale value as defined below. If that doesn't work, try adding the bbox value as well. If you're still having problems, let me know.
* @param scale
* A number corresponding to how many meters one meter of our map
* represents. A value "50000" would mean 1:50K which means for
* every meter of our map it represents 50000 meters of real
* world distance.
* @param bbox
* The viewable area of the map. Passed in the format of a string
* "lowerLeftX,lowerLeftY,upperRightX,upperRightY." Not required
* but can speed up rendering in some cases. example:
* "-50.4,23.6,-42.2,24.2"
Hi Michael. The scale didn't appear to have any effect on my lines. Whether it's 1.0, 1000, 50000, or 100000, the lines render the same and my distance calculation between them is the same.
Adding the bbox value did change some things, but did not resolve my issue and introduced complications. The first three rendered wonky at different values for the bounding box, and the final one actually rendered, but the line isn't entirely accurate and the distance between lines is still incorrect.
The squiggly lines here actually should be straight.
I'm going to try to look into it when I get some time. But try format=2. 1 is an older JSON based format that we didn't keep up. 2 is GeoJSON. Apparently I need to go back and correct some documentation.
Also, could the squiggles be a result of the symbol being draped across the terrain? Does the map you're using have elevation data?
RE: squiggles, we don't have terrain on this test, but this could be some weird bbox distortion I'm seeing here.
Changing the format did not produce a different result, and I'm pulling the coords out of the JSON anyway to build in czml.
I should note that on further testing, changing the scale did produce a different output as long as I didn't set bbox, but it still produced incorrect results. There was not an integer between 1 and 100,000 that would give me the proper size between lines with a 2,000 meter buffer (and I believe that would hold true with larger buffers).
Thanks again for looking into this for me.
So you're calculating point N to be a specific distance perpendicular to the line from point 1 to point 2 and the side corner of the arrowhead isn't lining up with that point when rendered? (Not counting the bizarre results you got when using bbox)
Your first screenshot looks like point N is too close to point 1 and it is making the arrowhead too flat and the sides are getting exaggerated by the extreme angle. Probably something we could've auto-corrected for in the renderer but aren't.
I assume you're expecting something like this:

Can I get a version of the first screenshot from your first post in this issue with the symbol coordinates on the map highlighted or marked?
for reference:

Those graphics are a huge help, and displaying the points on my map for you helped me figure out that I needed to change how I was calculating my angle. I'm getting closer now.
However, after implementing the fix I'm still showing inexact results in what still seems like a different angle issue. Right now I grab the heading (from north) of the final point and add 135 degrees to that point so the buffer point is at a 45 degree angle.
The first picture below, in which the path is about 45 degrees from north, has an error of 30 meters more than expected. The second one, about 90 degrees from north, as an error of 14 meters more than expected. The third one, which is nearly at north, has an error of 16 meters less than expected.



I've also tried other algorithms and libraries to see if a the way I'm calculating the bearing might be wrong. That doesn't seem to be the case. I'm also getting the distance by Math.sqrt(Math.pow(5000,2) + Math.pow(5000,2)).
When you're saying the symbol has an error of 30 meters, what is off by 30 meters? The entire symbol? The corner of the arrow in relation to the buffer point? Something else?
Also, what map engine are you using? Where are the control points in relation to the text markers? Is the text centered on them?
What I'm doing is taking the first two points of each line in the json output and calculating the distance between using Vincenty's direct formula. So the distance between those points is off by the above error values.
I'm using Cesium for the map - specifically an AGI library for various calculations and object types (though I've also checked their calculations against "the long way" to verify those were not the problem) . The control points are centered on the text, though instead of the text I can give you something more precise if that would help.
Might be easier to visualize with something more precise.
Also, can you give me the coordinates for you last set of screenshots? I was going to dump the values in the EMP-Web sample and see what happens. They use Cesium as well. https://missioncommand.github.io/docs/emp/web/index.html#pages/example.html?example=examples/create-mil-multipoint.js
No problem! I see they have a specific way of inputting latitude/longitude, so I did some processing on the points and split up the different parts into separate files. Hopefully this makes it easier. coords0 and coords1 are the corridor lines and coords2 is the arrow. If you need all this in a different format let me know.
coords0.txt
coords1.txt
coords2.txt
I'm sorry, I meant the original coordinates you sent into the renderer. Not the resulting values.
Anyway, I talked to someone who used to work on EMP-Web and they had accuracy issues as well.
They switched to using RenderSymbol2D() in mil-sym-js. This function was meant for two-dimensional map engines but seems to work better than RenderSymbol() for Cesium:
https://github.com/missioncommand/mil-sym-js/blob/master/web/js/src/sec/web/renderer/SECWebRenderer.js#L174
Wiki entry describing parameters: https://github.com/missioncommand/mil-sym-js/wiki/Developer%27s-Guide#33multipoint-symbology
That gave them the best results for Cesium.
There is an equivalent function in the Java port. Parameters are the same except the Java version doesn't support GeoCanvas or GeoSVG formats.
https://github.com/missioncommand/mil-sym-java/blob/master/renderer/mil-sym-renderer/src/main/java/sec/web/renderer/SECWebRenderer.java#L823
Believe it or not, this produced far worse results for me - now on a 5,000 meter width I'm off by more than 600 meters. I gathered the original coordinates and hope you can check them out. Pick whichever format better suits you.
For the RenderSymbol2D I used 1,500 for pixel width and length.
Is there a specific class or method that uses this buffer point to calculate the width? I tried stepping through on my debugger, but couldn't catch the right point at which that value gets set to see what's going on.
For RenderSymbol2d(), Pixel width and height should match the width and height of your map window. Bbox is also now required.
I'll have to look at the code. The person who wrote the multipoint rendering code retired so I'm not sure where the magic happens but I have an idea of where to look.
I believe this is how the EMP-Web team was getting their bbox values:
getExtent() https://github.com/missioncommand/emp3-web/blob/master/src/mapengine/cesium/js/lib/cesium/EmpCesium.js#L9991 getExtentApproximation() https://github.com/missioncommand/emp3-web/blob/master/src/mapengine/cesium/js/lib/cesium/EmpCesium.js#L10010
And their values for pixel width and height: this.canvas.width, this.canvas.height where this.canvas = this.scene.canvas; https://github.com/missioncommand/emp3-web/blob/master/src/mapengine/cesium/js/lib/cesium/EmpCesium.js#L7081
Now they're using the GeoSVG format and not GeoJSON so there's whatever potential differences that go along plotting points vs draping an SVG on the map. But the results should be close.
OK, some updates from my end. Using SECWebRenderer is not an option for us since the applet breaks our CI/CD pipeline, so I'm using SECRenderer, and that's why the method names I'm referencing are a little different from the ones you're referencing.
Regarding the 2D method, the max pixel value is 1,000 but when we launch our application, our pixel width and height is regularly over that number and also variable. When I tried inserting static numbers (since we don't have the front and back end hooked up yet and I can't get them from the Java code) I can't get close with standard screen resolutions, and changing that argument fluctuates the observed error.
For instance, at 640x360 pixels and 5000 meters width argument, I get an error of 188. At 8000 meters, my error jumps to 646. The 2D method is also still subject to the issue I've been having with different path angles returning different widths.
I was able to get the bbox working on RenderMultiPointSymbol() to the point where different angles give me a consistent observed width, however, changing the argument gives me more result errors. Right now I can get within 2 meters at a 5,000 meter set width, but when I bump it up to 7,000 meters or down to 3,000 meters, I'm looking at a margin of error of 330 meters and 500 meters, respectively.