{ "X3D": {
    "encoding":"UTF-8",
    "@profile":"Immersive",
    "@version":"3.3",
    "@xsd:noNamespaceSchemaLocation":"https://www.web3d.org/specifications/x3d-3.3.xsd",
    "JSON schema":"https://www.web3d.org/specifications/x3d-4.0-JSONSchema.autogenerated.json",
    "head": {
        "component": [
          {
            "@name":"Geospatial",
            "@level":1
          }
        ],
        "meta": [
          {
            "@name":"title",
            "@content":"KmlPrototypes.x3d"
          },
          {
            "@name":"description",
            "@content":"X3D prototypes to render Keyhole Markup Language (KML) information."
          },
          {
            "@name":"translated",
            "@content":"20 August 2007"
          },
          {
            "@name":"modified",
            "@content":"20 October 2019"
          },
          {
            "@name":"creator",
            "@content":"Don Brutzman"
          },
          {
            "@name":"warning",
            "@content":"under development"
          },
          {
            "@name":"identifier",
            "@content":"https://www.web3d.org/x3d/content/examples/Basic/Geospatial/KmlPrototypes.x3d"
          },
          {
            "@name":"reference",
            "@content":"http://www.opengeospatial.org/standards/kml"
          },
          {
            "@name":"reference",
            "@content":"http://schemas.opengis.net/kml"
          },
          {
            "@name":"reference",
            "@content":"http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd"
          },
          {
            "@name":"reference",
            "@content":"KmlToX3d.xslt"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"02 September 2025"
          },
          {
            "@name":"generator",
            "@content":"X3dToJson.xslt, https://www.web3d.org/x3d/stylesheets/X3dToJson.html"
          },
          {
            "@name":"reference",
            "@content":"X3D JSON encoding: https://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
          }
        ]
    },
    "Scene": {
        "-children":[
          { "ProtoDeclare":
            {
              "@name":"PlaceMark",
              "@appinfo":"A Placemark with a Point has an icon associated with it that marks a point on the earth in the 3D viewer.",
              "@documentation":"http://code.google.com/apis/kml/documentation/kml_tags_21.html#placemark",
              "ProtoInterface": {
                  "field": [
                    {
                      "@name":"id",
                      "@accessType":"initializeOnly",
                      "@type":"SFString"
                    },
                    {
                      "@name":"name",
                      "@accessType":"inputOutput",
                      "@appinfo":"Label for the object",
                      "@type":"MFString"
                    },
                    {
                      "@name":"description",
                      "@accessType":"inputOutput",
                      "@appinfo":"User-supplied text that appears in the description balloon",
                      "@type":"SFString"
                    },
                    {
                      "@name":"coordinates",
                      "@accessType":"initializeOnly",
                      "@appinfo":"longitude latitude and altitude",
                      "@type":"SFVec3d",
                      "@value":[0,0,0]
                    },
                    {
                      "@name":"address",
                      "@accessType":"inputOutput",
                      "@appinfo":"A string value representing an unstructured address written as a standard street city state address and/or as a postal code.",
                      "@type":"MFString"
                    },
                    {
                      "@name":"visibility",
                      "@accessType":"initializeOnly",
                      "@appinfo":". Specifies whether the feature is drawn in the 3D viewer when it is initially loaded",
                      "@type":"SFBool",
                      "@value":true
                    },
                    {
                      "@name":"set_visibility",
                      "@accessType":"inputOnly",
                      "@type":"SFBool"
                    },
                    {
                      "@name":"visibility_changed",
                      "@accessType":"outputOnly",
                      "@type":"SFBool"
                    },
                    {
                      "@name":"open",
                      "@accessType":"initializeOnly",
                      "@appinfo":"Specifies whether a Folder appears closed or open when first loaded",
                      "@type":"SFBool",
                      "@value":true
                    },
                    {
                      "@name":"snippet",
                      "@accessType":"initializeOnly",
                      "@appinfo":"A short description of the feature",
                      "@type":"MFString"
                    },
                    {
                      "@name":"set_snippet",
                      "@accessType":"inputOnly",
                      "@type":"MFString"
                    },
                    {
                      "@name":"snippet_changed",
                      "@accessType":"outputOnly",
                      "@type":"MFString"
                    },
                    {
                      "@name":"geometry",
                      "@accessType":"inputOutput",
                      "@appinfo":"Shape or (KML) Point LineString LinearRing Polygon MultiGeometry Model",
                      "@type":"MFNode",
                      "-children":[
                        {
                          "#comment":"default NULL node"
                        }
                      ]
                    },
                    {
                      "@name":"diffuseColor",
                      "@accessType":"inputOutput",
                      "@appinfo":"Default color for PlaceMark",
                      "@type":"SFColor",
                      "@value":[0.2,0.8,0.4]
                    },
                    {
                      "@name":"metadata",
                      "@accessType":"inputOutput",
                      "@type":"SFNode",
                      "-children":[
                        {
                          "#comment":"default NULL node"
                        }
                      ]
                    }
                  ],
                  "-children":[
                    {
                      "#comment":"TODO: is the 'open' parameter appropriate for X3D? Maintain value for round-trip conversions."
                    },
                    {
                      "#comment":"TODO: need LookAt Prototype"
                    },
                    {
                      "#comment":"TODO: AddressDetails, phoneNumber, TimePrimitive, styleUrl, StyleSelector, Region"
                    },
                    {
                      "#comment":"TODO: Geometry prototypes for KML Point,LineString,LinearRing, Polygon,MultiGeometry,Model"
                    }
                  ]
              },
              "ProtoBody": {
                  "-children":[
                    {
                      "#comment":"TODO: is Switch needed to choose between balloon and provided geometry, or are both shown?"
                    },
                    { "Switch":
                      {
                        "@DEF":"SwitchVisible",
                        "@whichChoice":0,
                        "-children":[
                          { "Anchor":
                            {
                              "IS": {
                                  "connect": [
                                    {
                                      "@nodeField":"url",
                                      "@protoField":"address"
                                    },
                                    {
                                      "@nodeField":"description",
                                      "@protoField":"description"
                                    }
                                  ]
                              },
                              "-children":[
                                { "GeoLocation":
                                  {
                                    "-geoOrigin":
                                      { "GeoOrigin":
                                        {
                                          "IS": {
                                              "connect": [
                                                {
                                                  "@nodeField":"geoCoords",
                                                  "@protoField":"coordinates"
                                                }
                                              ]
                                          }
                                        }
                                      }
                                  }
                                },
                                { "Shape":
                                  {
                                    "@DEF":"PlaceMarkBalloon",
                                    "-geometry":
                                      { "Extrusion":
                                        {
                                          "@creaseAngle":3.14,
                                          "@crossSection":[1.00,0.00,0.92,-0.38,0.71,-0.71,0.38,-0.92,0.00,-1.00,-0.38,-0.92,-0.71,-0.71,-0.92,-0.38,-1.00,-0.00,-0.92,0.38,-0.71,0.71,-0.38,0.92,0.00,1.00,0.38,0.92,0.71,0.71,0.92,0.38,1.00,0.00],
                                          "@scale":[0.01,0.01,0.03,0.03,0.06,0.06,0.09,0.09,0.14,0.14,0.23,0.23,0.25,0.25,0.23,0.23,0.18,0.18,0.1,0.1,0.03,0.03],
                                          "@spine":[0,0,0,0,0.12,0,0,0.28,0,0,0.4,0,0,0.55,0,0,0.65,0,0,0.75,0,0,0.85,0,0,0.92,0,0,0.98,0,0,1.0,0]
                                        }
                                      },
                                    "-appearance":
                                      { "Appearance":
                                        {
                                          "-material":
                                            { "Material":
                                              {
                                                "@DEF":"PlaceMarkMaterial",
                                                "IS": {
                                                    "connect": [
                                                      {
                                                        "@nodeField":"diffuseColor",
                                                        "@protoField":"diffuseColor"
                                                      }
                                                    ]
                                                }
                                              }
                                            }
                                        }
                                      }
                                  }
                                },
                                { "Transform":
                                  {
                                    "@DEF":"PlaceMarkName",
                                    "@translation":[0,1.2,0],
                                    "-children":[
                                      { "Shape":
                                        {
                                          "-geometry":
                                            { "Text":
                                              {
                                                "IS": {
                                                    "connect": [
                                                      {
                                                        "@nodeField":"string",
                                                        "@protoField":"name"
                                                      }
                                                    ]
                                                },
                                                "-fontStyle":
                                                  { "FontStyle":
                                                    {
                                                      "@justify":["MIDDLE","MIDDLE"],
                                                      "@size":0.2
                                                    }
                                                  }
                                              }
                                            },
                                          "-appearance":
                                            { "Appearance":
                                              {
                                                "-material":
                                                  { "Material":
                                                    {
                                                      "@USE":"PlaceMarkMaterial"
                                                    }
                                                  }
                                              }
                                            }
                                        }
                                      }
                                    ]
                                  }
                                },
                                { "Transform":
                                  {
                                    "@DEF":"SnippetTranslation",
                                    "@translation":[0,2.4,0],
                                    "-children":[
                                      { "Shape":
                                        {
                                          "-geometry":
                                            { "Text":
                                              {
                                                "IS": {
                                                    "connect": [
                                                      {
                                                        "@nodeField":"string",
                                                        "@protoField":"snippet"
                                                      }
                                                    ]
                                                },
                                                "-fontStyle":
                                                  { "FontStyle":
                                                    {
                                                      "@justify":["MIDDLE","MIDDLE"],
                                                      "@size":0.2
                                                    }
                                                  }
                                              }
                                            },
                                          "-appearance":
                                            { "Appearance":
                                              {
                                                "-material":
                                                  { "Material":
                                                    {
                                                      "@USE":"PlaceMarkMaterial"
                                                    }
                                                  }
                                              }
                                            }
                                        }
                                      }
                                    ]
                                  }
                                },
                                { "Group":
                                  {
                                    "@DEF":"GeometryGroup",
                                    "IS": {
                                        "connect": [
                                          {
                                            "@nodeField":"children",
                                            "@protoField":"geometry"
                                          }
                                        ]
                                    }
                                  }
                                }
                              ]
                            }
                          }
                        ]
                      }
                    },
                    {
                      "#comment":"remaining nodes in ProtoBody are not rendered"
                    },
                    { "WorldInfo":
                      {
                        "IS": {
                            "connect": [
                              {
                                "@nodeField":"title",
                                "@protoField":"id"
                              }
                            ]
                        }
                      }
                    },
                    { "Group":
                      {
                        "@DEF":"MetadataHolderPlaceMark",
                        "IS": {
                            "connect": [
                              {
                                "@nodeField":"metadata",
                                "@protoField":"metadata"
                              }
                            ]
                        }
                      }
                    },
                    { "Script":
                      {
                        "@DEF":"BehaviorScript",
                        "field": [
                          {
                            "@name":"visibility",
                            "@accessType":"initializeOnly",
                            "@type":"SFBool"
                          },
                          {
                            "@name":"set_visibility",
                            "@accessType":"inputOnly",
                            "@type":"SFBool"
                          },
                          {
                            "@name":"visibility_changed",
                            "@accessType":"outputOnly",
                            "@type":"SFBool"
                          },
                          {
                            "@name":"visibilityChoice",
                            "@accessType":"outputOnly",
                            "@type":"SFInt32"
                          },
                          {
                            "@name":"open",
                            "@accessType":"initializeOnly",
                            "@type":"SFBool"
                          },
                          {
                            "@name":"snippet",
                            "@accessType":"initializeOnly",
                            "@type":"MFString"
                          },
                          {
                            "@name":"set_snippet",
                            "@accessType":"inputOnly",
                            "@type":"MFString"
                          },
                          {
                            "@name":"snippet_changed",
                            "@accessType":"outputOnly",
                            "@type":"MFString"
                          },
                          {
                            "@name":"snippetOffset",
                            "@accessType":"outputOnly",
                            "@type":"SFVec3f"
                          }
                        ],
                        "IS": {
                            "connect": [
                              {
                                "@nodeField":"visibility",
                                "@protoField":"visibility"
                              },
                              {
                                "@nodeField":"set_visibility",
                                "@protoField":"set_visibility"
                              },
                              {
                                "@nodeField":"visibility_changed",
                                "@protoField":"visibility_changed"
                              },
                              {
                                "@nodeField":"open",
                                "@protoField":"open"
                              },
                              {
                                "@nodeField":"snippet",
                                "@protoField":"snippet"
                              },
                              {
                                "@nodeField":"set_snippet",
                                "@protoField":"set_snippet"
                              },
                              {
                                "@nodeField":"snippet_changed",
                                "@protoField":"snippet_changed"
                              }
                            ]
                        },
                        "#sourceCode":[
"",
"",
"ecmascript:",
"",
"function initialize ()",
"{",
"\tBrowser.println ('visibility=' + visibility);",
"\tif (visibility == false) visibilityChoice = -1;",
"",
"\t// TODO:  if (open == false) open_changed = -1;",
"",
"\tadjustSnippetOffset ();",
"}",
"",
"function set_visibility (value, timestamp)",
"{",
"\tvisibility = value;         // remember change",
"\tvisibility_changed = value; // send eventOut",
"\tif (visibility == false) visibilityChoice = -1;",
"\telse                     visibilityChoice =  0;",
"}",
"",
"function set_snippet (value, timestamp)",
"{",
"\tsnippet = value;         // remember change",
"\tsnippet_changed = value; // send eventOut",
"\tadjustSnippetOffset ();",
"}",
"",
"function adjustSnippetOffset () // TODO",
"{",
"//\tsnippetOffset = new SFVec3f (0.0, (snippet.length * 0.3), 0.0);",
"//\tBrowser.println ('snippet.length=' + snippet.length + ', snippetOffset=' + snippetOffset);",
"}",
"",
"function set_open (value, timestamp) // TODO",
"{",
"",
"}",
"",
""
]
                      }
                    },
                    { "ROUTE":
                      {
                        "@fromField":"visibilityChoice",
                        "@fromNode":"BehaviorScript",
                        "@toField":"whichChoice",
                        "@toNode":"SwitchVisible"
                      }
                    },
                    { "ROUTE":
                      {
                        "@fromField":"snippetOffset",
                        "@fromNode":"BehaviorScript",
                        "@toField":"set_translation",
                        "@toNode":"SnippetTranslation"
                      }
                    }
                  ]
              }
            }
          },
          { "ProtoDeclare":
            {
              "@name":"Point",
              "@appinfo":"A geographic location defined by longitude latitude and (required) altitude.",
              "@documentation":"http://code.google.com/apis/kml/documentation/kml_tags_21.html#point",
              "ProtoInterface": {
                  "field": [
                    {
                      "@name":"id",
                      "@accessType":"initializeOnly",
                      "@type":"SFString"
                    },
                    {
                      "@name":"altitudeMode",
                      "@accessType":"initializeOnly",
                      "@appinfo":"allowed values: clampToGround relativeToGround absolute",
                      "@type":"SFString",
                      "@value":"clampToGround"
                    },
                    {
                      "@name":"coordinates",
                      "@accessType":"initializeOnly",
                      "@type":"SFVec3d",
                      "@value":[0,0,0]
                    },
                    {
                      "@name":"set_coordinates",
                      "@accessType":"inputOnly",
                      "@type":"SFVec3d"
                    },
                    {
                      "@name":"coordinates_changed",
                      "@accessType":"outputOnly",
                      "@type":"SFVec3d"
                    },
                    {
                      "@name":"extrude",
                      "@accessType":"initializeOnly",
                      "@type":"SFBool",
                      "@value":false
                    },
                    {
                      "@name":"tessellate",
                      "@accessType":"initializeOnly",
                      "@type":"SFBool",
                      "@value":false
                    },
                    {
                      "@name":"metadata",
                      "@accessType":"inputOutput",
                      "@type":"SFNode",
                      "-children":[
                        {
                          "#comment":"default NULL node"
                        }
                      ]
                    }
                  ]
              },
              "ProtoBody": {
                  "-children":[
                    { "Script":
                      {
                        "@DEF":"PointScript",
                        "field": [
                          {
                            "@name":"altitudeMode",
                            "@accessType":"initializeOnly",
                            "@type":"SFString"
                          },
                          {
                            "@name":"coordinates",
                            "@accessType":"initializeOnly",
                            "@type":"SFVec3d"
                          },
                          {
                            "@name":"set_coordinates",
                            "@accessType":"inputOnly",
                            "@type":"SFVec3d"
                          },
                          {
                            "@name":"coordinates_changed",
                            "@accessType":"outputOnly",
                            "@type":"SFVec3d"
                          },
                          {
                            "@name":"extrude",
                            "@accessType":"initializeOnly",
                            "@type":"SFBool"
                          },
                          {
                            "@name":"tessellate",
                            "@accessType":"initializeOnly",
                            "@type":"SFBool"
                          }
                        ],
                        "IS": {
                            "connect": [
                              {
                                "@nodeField":"altitudeMode",
                                "@protoField":"altitudeMode"
                              },
                              {
                                "@nodeField":"coordinates",
                                "@protoField":"coordinates"
                              },
                              {
                                "@nodeField":"set_coordinates",
                                "@protoField":"set_coordinates"
                              },
                              {
                                "@nodeField":"coordinates_changed",
                                "@protoField":"coordinates_changed"
                              },
                              {
                                "@nodeField":"extrude",
                                "@protoField":"extrude"
                              },
                              {
                                "@nodeField":"tessellate",
                                "@protoField":"tessellate"
                              }
                            ]
                        },
                        "#sourceCode":[
"",
"",
"ecmascript:",
"",
"function initialize ()",
"{",
"\tif  (altitudeMode == '') altitudeMode = 'clampToGround';",
"\tif ((altitudeMode != 'clampToGround') &&",
"\t    (altitudeMode != 'relativeToGround') &&",
"\t    (altitudeMode != 'absolute'))",
"\t{",
"\t\twarningString = '[Point';",
"\t\tif (id != '') warningString += ' ' + id;",
"\t\twarningString += '] illegal value ';",
"\t\twarningString += 'altitudeMode=' + altitudeMode;",
"\t\tBrowser.println (warningString);",
"\t}",
"}",
"",
"function set_coordinates (value)",
"{",
"\tcoordinates = value;",
"\tcoordinates_changed = value;",
"}",
"",
"// TODO: how to handle extrude, tessellate",
"",
""
]
                      }
                    },
                    { "WorldInfo":
                      {
                        "IS": {
                            "connect": [
                              {
                                "@nodeField":"title",
                                "@protoField":"id"
                              }
                            ]
                        }
                      }
                    },
                    { "Group":
                      {
                        "@DEF":"MetadataHolderPoint",
                        "IS": {
                            "connect": [
                              {
                                "@nodeField":"metadata",
                                "@protoField":"metadata"
                              }
                            ]
                        }
                      }
                    }
                  ]
              }
            }
          },
          {
            "#comment":"========== Examples =========="
          },
          { "Viewpoint":
            {
              "@description":"Placemark example",
              "@position":[0,0,4]
            }
          },
          {
            "#comment":"<?xml version=\"1.0\" encoding=\"UTF-8\"?> <kml xmlns=\"http://earth.google.com/kml/2.1\"> <Placemark> <name>Simple placemark</name> <description>Attached to the ground. Intelligently places itself at the height of the underlying terrain.</description> <Point> <coordinates>-122.0822035425683,37.42228990140251,0</coordinates> </Point> </Placemark> </kml>"
          },
          { "ProtoInstance":
            {
              "@name":"PlaceMark",
              "fieldValue": [
                {
                  "@name":"name",
                  "@value":["Simple placemark"]
                },
                {
                  "@name":"description",
                  "@value":"Attached to the ground. Intelligently places itself at the height of the underlying terrain."
                },
                {
                  "@name":"coordinates",
                  "@value":[-122.0822035425683,37.42228990140251,0]
                },
                {
                  "@name":"address",
                  "@value":["https://www.web3d.org/x3d-earth"]
                }
              ]
            }
          }
        ]
    }
  }
}