Open ComBatVision opened 7 years ago
It's misleading to call these mistakes. There are two key points that I'm hoping will clarify:
What you describe here are intentional design decisions intended to reduce memory usage for very large numbers of MilStd2525 icons. Something on the order of 30,000. By sharing a common set of attributes, both the attribute bundle and the associated image source are shared by all shapes for low and medium levels of detail. Cloning the attributes could defeat that, depending on how clone is implemented.
This code is in the worldwind-examples module, and is intended as just that. We intentionally left these design decisions up to the application developer. Please do apply whatever design is appropriate for your application, using our MilStd2525 rendering examples as a guide.
Regarding the difference in rendering libraries for MIL-STD-2525 on Android. We're experimenting with integrating existing MilStd2525 rendering library from the mission command GitHub repository: https://github.com/missioncommand/mil-sym-android
I understand that milstd code is just an example outside the library, but when I have tested this example I found it working incorrect. Please, try to add 100 MilStd2525Placemarks on some layer with random T1 title modificator. You will see that without cloning of modificators all of your Placemarks will have the same caption text like the last one. Even your example Activity has this bug if you will try to create Placemark not via MilStd2525.java class, but try to create the same 3 plasemarks using MilStd2525Placemark.java
And about rendering library. I see that examples contains MissionComand library integration, but why do not you use symbology module from WorldWindJava? Why you decided to use MissionCommand library in Android version?
Thanks for clarifying; we'll have a look at how the MilStd2525Placemark example is handling text modifiers when we have time.
Regarding the rendering library, we'd prefer to integrate an existing and well supported library to porting the library from Java. Our own MIL-STD-2525 library is well designed, but is not straightforward to port to Android. In general, our preference is to approach Android capabilities with an eye toward simplification and optimization. Often this means that the existing Java implementation isn't appropriate to port.
Thanks for your explanation.
Please confirm to close this question - you do not plan to port Java rendering version to Android in nearest future and if I do some project based on WorldWind it is better to start doing it with MissionComand library for Android and Web version and proprietary code for Java version? Am I right?
And about the issue, here is my modification propositions...
MilStd2525Placemark.java:
public MilStd2525Placemark(Position position, String symbolCode, SparseArray<String> modifiers, SparseArray<String> attributes) {
super(position, null /* attribute bundle */, symbolCode /* name */);
// Set the properties used to create the bitmap in the level of detail selector
this.symbolCode = symbolCode;
this.modifiers = modifiers != null ? modifiers.clone() : null;
this.attributes = attributes != null ? attributes.clone() : null;
this.setLevelOfDetailSelector(new MilStd2525LevelOfDetailSelector());
}
PlacemarksMilStd2525Activity.java: Replace all occurences of..
Placemark machineGun = new Placemark(Position.fromDegrees(32.3902, 63.4161, 0),
MilStd2525.getPlacemarkAttributes("SFGPEWRH--MTUSG", modifiers, null));
with:
MilStd2525Placemark machineGun = new MilStd2525Placemark(Position.fromDegrees(32.3902, 63.4161, 0),
"SFGPEWRH--MTUSG", modifiers, null);
MilStd2525LevelOfDetailSelector: protected static double NEAR_THRESHOLD = 30000;
That's correct, we do not play to port the Java MIL-STD-2525 library to Android. We're having success with the MissionCommand MIL-STD-2525 rendering library, and it's well supported on Android.
Regarding your changes, I appreciate your outlining what's you think is necessary to resolve this issue. We won't be applying any changes to the MIL-STD-2525 examples until we've had a chance to review the problem.
The code samples above solve the same problem. 1) Replace direct array assignation in placemark constructor with clone. To have own modifiers table for each placemark. 2) Use MilStd252Placemark instead of standard Placemark to activate LevelOfDetails functionality and see the problem itself. 3) Not related to the problem - incorrect threshold. You may not change it. It is just usability issue.
MilStd2525Placemark should store clones of modifiers and attributes in its constructor (the same way as in BitmapFactory of MilStd2525 class does):
Now parameters are directly assigned to private appributes of class and there is a following bug. When creating series of WorldWind Placemarks using the same modifiers and attributes array in a "for" cycle, then in the result you will see that after change LevelOfDetails all created Placemarks will take modifiers and attributes from the last created Placemark in cycle, because all of them will store the same instance of modifiers and attributes lists in memory, which was modified during creation cycle.
And one more proposition - to change default value of near threshold in MilStd2525LevelOfDetails class from 300000 to 30000, because in other way both thresholds are very close to each other and middle level of details almost never appears. protected static double NEAR_THRESHOLD = 30000;
And yet another question - why Android and Java version of WorldWind uses different rendering librarioes for tactical graphics? What library will be the main in future? Why Java symbology code was not ported to android? Any technical reasons? https://forum.worldwindcentral.com/forum/worldwind-android-wwa/android-discussion/156816-why-android-version-uses-not-the-same-mil-std-2525-rendering-library-as-java-version