[x3d-public] X3DJSAIL--GeoLOD.setRootNode vs. GeoLOD.addRootNode

John Carlson yottzumm at gmail.com
Sun Apr 17 22:33:51 PDT 2022


Original X3D:
  <Scene>
    <WorldInfo title='SquawLOD023.x3d'/>
    <GeoLOD center='4344125.917539 741821.999947 1970.5' geoSystem='"UTM"
"Z10" "N"' range='0.0'>
      <GeoOrigin DEF='ORIGIN' geoCoords='4342525.5 740604 0'
geoSystem='"UTM" "Z10" "N"' rotateYUp='true'/>
      <Shape containerField='rootNode'>

My method maps at least temporarily, do not have setRootNode in them (my
code now lists addRootNode).  And the Java is currently addRootNode.

So things appear to be better, but...maybe addRootNode also doesn't
register?

See output JSON:

              "-children":[
                { "Shape":
                  {

-children should be -rootNode as is in original JSON.

              "-rootNode":[
                { "Shape":
                  {

Here's the Java results, Don's first, mine second:

$ java -cp '.;C:/Users/john/pythonSAI/X3DJSAIL.4.0.full.jar'
net/x3djsonld/data/SquawLOD023
Java program "net.x3djsonld.data.SquawLOD023" self-validation test results:
success

$ java -cp '.;C:/Users/john/pythonSAI/X3DJSAIL.4.0.full.jar'
net/coderextreme/data/SquawLOD023
successNote: toFileStylesheetConversion(X3dToJson.xslt) is overwriting
prior file ../data/SquawLOD023.new.json
... containerField mismatch for Shape DEF='', found
containerField='children' but expected containerField='rootNode'

So it's pretty obvious, I think, that the error may be in my code, but
let's add JSON export to Don's:

$ java -cp '.;C:/Users/john/pythonSAI/X3DJSAIL.4.0.full.jar'
net/x3djsonld/data/SquawLOD023
Java program "net.x3djsonld.data.SquawLOD023" self-validation test results:
success
Note: toFileStylesheetConversion(X3dToJson.xslt) is overwriting prior file
../data/SquawLOD023.new.json
... containerField mismatch for Shape DEF='', found
containerField='children' but expected containerField='rootNode'

And the bug appears in the new.json file!

"-children":[
{ "Shape":
{

Okay, so we've got to look at the intermediate XML code output from X3DJSAIL

And the XML does not have a containerField
attribute,see:  SquawLOD023.newPrettyPrint.intermediate.x3d

      <Shape>

So now we have to track down why Shape does not have a containerField in
X3DJSAIL.

Gotta rest for now.  If someone wants to follow up on this, I suggest
tracking back from where containerField=' is output in Shape.java (but it
may be somewhere else).

This code seems like the likeliest place in Shape.java.  Somehow we need
the if statement to succeed in the case of a rootNode containerField
(others?).

            // containerField is critical for ProtoInstance relationship to
parent node
            if (!getContainerFieldOverride().isEmpty() &&
!getContainerFieldOverride().equals(this.getContainerFieldDefault())) //
output if not default ProtoInstance containerField
            {
                    stringX3D.append(" *containerField='*
").append(getContainerFieldOverride()).append("'");
            }

Best of luck to you!

John



On Wed, Apr 13, 2022 at 5:09 PM John Carlson <yottzumm at gmail.com> wrote:

> Possible issue with X3DJSAIL, GeoLOD.setRootNode (containerField mismatch
> for Shape DEF='', found containerField='children' but expected
> containerField='rootNode') compared to GeoLOD.addRootNode (validates).
> Reading Javadoc, it says there may be multiple rootNodes, so addRootNode
> makes sense.
>
> Upon review, there is setRootNode in my Java code, so I'm not sure why
> there’s an error (above) running it???
>
> I reviewed the output of X3dToJava.xslt--This uses addRootNode.   Should I
> change setRootNode to addRootNode in my serializers?  It won't be the first
> time I do something like this.
>
> If I’m doing this solo, ok.   Any clarification why addRootNode validates,
> but setRootNode doesn't, would help.   But I’m making mistakes in my
> review, feeling a bit scrambled, wondering.  If there will be no changes to
> X3DJSAIL, I'll probably have to change my serializers.
>
> I did make a suggestion to use setRootNode to set what goes into the XML
> output (containerField=“rootNode” on Shape), but it seems like that
> suggestion has fallen on deaf ears.  That is, we want to bury
> containerField, but it keeps cropping up.  Can we do something better with
> X3DJSAIL (and serializers) than subverting the programmer's intention?
>
> I will take a peek at X3DUOM now.  It looks like the default container
> Field for shape (which I think is the node in question), is set to
> "children".  I can't recommend a better default containerField value.
>
> In my serializers, I think I purposefully use setRootNode on the first
> child, but I will have to double check.
>
> It would seem like if the container field has type MFNode, I should use
> add.
>
> On Sat, Apr 9, 2022 at 7:43 PM John Carlson <yottzumm at gmail.com> wrote:
>
>> interesting "issues" while running Java generated by JavaSerializer.js.
>> Sample attached.
>>
>> Note that the SquawLOD023.x3d.new (intermediate between JSON and Java)
>> does not contain the containerField='rootNode' that the XML file has.
>> Should I explicitly set the containerField on Shape?
>>
>> Note that the .new.json does not contain a containerField either, nor
>> does the JSON generated from XML, that the serializer uses as input.
>>
>> Can someone explain why the containerField was supposed to be
>> 'rootNode'?   Can we get the X3dToJson.xslt to produce a rootNode
>> containerField for this case?
>>
>>
>> I'm guessing this is on a TODO list somewhere.
>>
>>
>>
>> ~/X3DJSONLD/src/main/java ~/X3DJSONLD/src/main/shell
>>
>> net/coderextreme/x3d_code/www_web3d_org/x3d/content/examples/Basic/Geospatial/SquawLOD023
>> success... containerField mismatch for Shape DEF='', found
>> containerField='children' but expected containerField='rootNode'
>> ~/X3DJSONLD/src/main/shell
>> ~/X3DJSONLD/src/main/java ~/X3DJSONLD/src/main/shell
>>
>> net/coderextreme/x3d_code/www_web3d_org/x3d/content/examples/Basic/Geospatial/SquawLOD024
>> success... containerField mismatch for Shape DEF='', found
>> containerField='children' but expected containerField='rootNode'
>> ~/X3DJSONLD/src/main/shell
>> ~/X3DJSONLD/src/main/java ~/X3DJSONLD/src/main/shell
>>
>> net/coderextreme/x3d_code/www_web3d_org/x3d/content/examples/Basic/Geospatial/SquawLOD025
>> success... containerField mismatch for Shape DEF='', found
>> containerField='children' but expected containerField='rootNode'
>> ~/X3DJSONLD/src/main/shell
>> ~/X3DJSONLD/src/main/java ~/X3DJSONLD/src/main/shell
>>
>> net/coderextreme/x3d_code/www_web3d_org/x3d/content/examples/Basic/Geospatial/SquawLOD026
>> success... containerField mismatch for Shape DEF='', found
>> containerField='children' but expected containerField='rootNode'
>> ~/X3DJSONLD/src/main/shell
>> ~/X3DJSONLD/src/main/java ~/X3DJSONLD/src/main/shell
>>
>> net/coderextreme/x3d_code/www_web3d_org/x3d/content/examples/Basic/Geospatial/SquawLOD027
>> success... containerField mismatch for Shape DEF='', found
>> containerField='children' but expected containerField='rootNode'
>> ~/X3DJSONLD/src/main/shell
>> ~/X3DJSONLD/src/main/java ~/X3DJSONLD/src/main/shell
>>
>> net/coderextreme/x3d_code/www_web3d_org/x3d/content/examples/Basic/Geospatial/SquawLOD028
>> success... containerField mismatch for Shape DEF='', found
>> containerField='children' but expected containerField='rootNode'
>> ~/X3DJSONLD/src/main/shell
>> ~/X3DJSONLD/src/main/java ~/X3DJSONLD/src/main/shell
>>
>> net/coderextreme/x3d_code/www_web3d_org/x3d/content/examples/Basic/Geospatial/SquawLOD029
>> success... containerField mismatch for Shape DEF='', found
>> containerField='children' but expected containerField='rootNode'
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20220418/a32dc203/attachment.html>


More information about the x3d-public mailing list