<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "https://www.web3d.org/specifications/x3d-3.3.dtd">
<X3D profile='Immersive'  version='3.3 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation =' https://www.web3d.org/specifications/x3d-3.3.xsd ' >
<head>
<component level='1name='Geospatial'/>
<meta name='titlecontent=' KmlPrototypes.x3d '/>
<meta name='descriptioncontent='X3D prototypes to render Keyhole Markup Language (KML) information.'/>
<meta name='translatedcontent='20 August 2007'/>
<meta name='modifiedcontent='20 October 2019'/>
<meta name='creatorcontent='Don Brutzman'/>
<meta name=' warning content=' under development '/>
<meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Basic/Geospatial/KmlPrototypes.x3d '/>
<meta name='referencecontent=' http://www.opengeospatial.org/standards/kml '/>
<meta name='referencecontent=' http://schemas.opengis.net/kml '/>
<meta name='referencecontent=' http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd '/>
<meta name='referencecontent=' KmlToX3d.xslt '/>
<meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../license.html'/>
</head>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- Index for DEF nodes: BehaviorScript, GeometryGroup, MetadataHolderPlaceMark, MetadataHolderPoint, PlaceMarkBalloon, PlaceMarkMaterial, PlaceMarkName, PointScript, SnippetTranslation, SwitchVisible

Index for Viewpoint node: Viewpoint_1

Index for ProtoDeclare definitions: PlaceMark, Point
-->
<Scene>
<ProtoDeclare name='PlaceMarkappinfo='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='idtype='SFStringaccessType='initializeOnly'/>
<field name='nametype='MFStringaccessType='inputOutput'
 appinfo='Label for the object' />

<field name='descriptiontype='SFStringaccessType='inputOutput'
 appinfo='User-supplied text that appears in the description balloon' />

<field name='coordinatestype='SFVec3dvalue='0 0 0accessType='initializeOnly'
 appinfo='longitude latitude and altitude' />

<field name='addresstype='MFStringaccessType='inputOutput'
 appinfo='A string value representing an unstructured address written as a standard street city state address and/or as a postal code.' />

<field name='visibilitytype='SFBoolvalue='trueaccessType='initializeOnly'
 appinfo='. Specifies whether the feature is drawn in the 3D viewer when it is initially loaded' />

<field name='set_visibilitytype='SFBoolaccessType='inputOnly'/>
<field name='visibility_changedtype='SFBoolaccessType='outputOnly'/>
<!-- TODO: is the 'open' parameter appropriate for X3D? Maintain value for round-trip conversions. -->
<field name='opentype='SFBoolvalue='trueaccessType='initializeOnly'
 appinfo='Specifies whether a Folder appears closed or open when first loaded' />

<!-- TODO: need LookAt Prototype -->
<field name='snippettype='MFStringaccessType='initializeOnly'
 appinfo='A short description of the feature' />

<field name='set_snippettype='MFStringaccessType='inputOnly'/>
<field name='snippet_changedtype='MFStringaccessType='outputOnly'/>
<!-- TODO: AddressDetails, phoneNumber, TimePrimitive, styleUrl, StyleSelector, Region -->
<!-- TODO: Geometry prototypes for KML Point,LineString,LinearRing, Polygon,MultiGeometry,Model -->
<field name='geometrytype='MFNodeaccessType='inputOutput'
 appinfo='Shape or (KML) Point LineString LinearRing Polygon MultiGeometry Model' >
<!-- default NULL node -->
</field>
<field name='diffuseColortype='SFColorvalue='0.2 0.8 0.4accessType='inputOutput'
 appinfo='Default color for PlaceMark' />

<field name='metadatatype='SFNodeaccessType='inputOutput'>
<!-- default NULL node -->
</field>
</ProtoInterface>
<ProtoBody>
<!-- TODO: is Switch needed to choose between balloon and provided geometry, or are both shown? -->
<!-- ROUTE information for SwitchVisible node:  [from BehaviorScript.visibilityChoice to whichChoice ] -->
<Switch DEF='SwitchVisiblewhichChoice='0'>
<Anchor>
<IS>
<connect nodeField='urlprotoField='address'/>
<connect nodeField='descriptionprotoField='description'/>
</IS>
<GeoLocation containerField='children'>
<GeoOrigin>
<IS>
<connect nodeField='geoCoordsprotoField='coordinates'/>
</IS>
</GeoOrigin>
</GeoLocation>
<Shape DEF='PlaceMarkBalloon'>
<Extrusion creaseAngle='3.14crossSection='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.00scale='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.03spine='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>
<Material DEF='PlaceMarkMaterial'>
<IS>
<connect nodeField='diffuseColorprotoField='diffuseColor'/>
</IS>
</Material>
</Appearance>
</Shape>
<Transform DEF='PlaceMarkNametranslation='0 1.2 0'>
<Shape>
<Text>
<IS>
<connect nodeField='stringprotoField='name'/>
</IS>
<FontStyle justify='"MIDDLE" "MIDDLE"size='0.2'/>
</Text>
<Appearance>
<Material USE=' PlaceMarkMaterial'/>
</Appearance>
</Shape>
</Transform>
<!-- ROUTE information for SnippetTranslation node:  [from BehaviorScript.snippetOffset to set_translation ] -->
<Transform DEF='SnippetTranslationtranslation='0 2.4 0'>
<Shape>
<Text>
<IS>
<connect nodeField='stringprotoField='snippet'/>
</IS>
<FontStyle justify='"MIDDLE" "MIDDLE"size='0.2'/>
</Text>
<Appearance>
<Material USE=' PlaceMarkMaterial'/>
</Appearance>
</Shape>
</Transform>
<Group DEF='GeometryGroup'>
<IS>
<connect nodeField='childrenprotoField='geometry'/>
</IS>
</Group>
</Anchor>
</Switch>
<!-- remaining nodes in ProtoBody are not rendered -->
<WorldInfo>
<IS>
<connect nodeField='titleprotoField='id'/>
</IS>
</WorldInfo>
<Group DEF='MetadataHolderPlaceMark'>
<IS>
<connect nodeField='metadataprotoField='metadata'/>
</IS>
</Group>
<field name='visibilitytype='SFBoolaccessType='initializeOnly'/>
<field name='set_visibilitytype='SFBoolaccessType='inputOnly'/>
<field name='visibility_changedtype='SFBoolaccessType='outputOnly'/>
<field name='visibilityChoicetype='SFInt32accessType='outputOnly'/>
<field name='opentype='SFBoolaccessType='initializeOnly'/>
<field name='snippettype='MFStringaccessType='initializeOnly'/>
<field name='set_snippettype='MFStringaccessType='inputOnly'/>
<field name='snippet_changedtype='MFStringaccessType='outputOnly'/>
<field name='snippetOffsettype='SFVec3faccessType='outputOnly'/>
<IS>
<connect nodeField='visibilityprotoField='visibility'/>
<connect nodeField='set_visibilityprotoField='set_visibility'/>
<connect nodeField='visibility_changedprotoField='visibility_changed'/>
<connect nodeField='openprotoField='open'/>
<connect nodeField='snippetprotoField='snippet'/>
<connect nodeField='set_snippetprotoField='set_snippet'/>
<connect nodeField='snippet_changedprotoField='snippet_changed'/>
</IS>
<![CDATA[
          
ecmascript:

function initialize ()
{
	Browser.println ('visibility=' + visibility);
	if (visibility == false) visibilityChoice = -1;

	// TODO:  if (open == false) open_changed = -1;

	adjustSnippetOffset ();
}

function set_visibility (value, timestamp)
{
	visibility = value;         // remember change
	visibility_changed = value; // send eventOut
	if (visibility == false) visibilityChoice = -1;
	else                     visibilityChoice =  0;
}

function set_snippet (value, timestamp)
{
	snippet = value;         // remember change
	snippet_changed = value; // send eventOut
	adjustSnippetOffset ();
}

function adjustSnippetOffset () // TODO
{
//	snippetOffset = new SFVec3f (0.0, (snippet.length * 0.3), 0.0);
//	Browser.println ('snippet.length=' + snippet.length + ', snippetOffset=' + snippetOffset);
}

function set_open (value, timestamp) // TODO
{

}

        
]]>
</Script>
< ROUTE  fromNode=' BehaviorScript' fromField='visibilityChoice' toNode=' SwitchVisible' toField='whichChoice'/>
< ROUTE  fromNode=' BehaviorScript' fromField='snippetOffset' toNode=' SnippetTranslation' toField='set_translation'/>
</ProtoBody>
</ProtoDeclare>
<ProtoDeclare name='Pointappinfo='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='idtype='SFStringaccessType='initializeOnly'/>
<field name='altitudeModetype='SFStringvalue='clampToGroundaccessType='initializeOnly'
 appinfo='allowed values: clampToGround relativeToGround absolute' />

<field name='coordinatestype='SFVec3dvalue='0 0 0accessType='initializeOnly'/>
<field name='set_coordinatestype='SFVec3daccessType='inputOnly'/>
<field name='coordinates_changedtype='SFVec3daccessType='outputOnly'/>
<field name='extrudetype='SFBoolvalue='falseaccessType='initializeOnly'/>
<field name='tessellatetype='SFBoolvalue='falseaccessType='initializeOnly'/>
<field name='metadatatype='SFNodeaccessType='inputOutput'>
<!-- default NULL node -->
</field>
</ProtoInterface>
<ProtoBody>
<Script DEF='PointScript'>
<field name='altitudeModetype='SFStringaccessType='initializeOnly'/>
<field name='coordinatestype='SFVec3daccessType='initializeOnly'/>
<field name='set_coordinatestype='SFVec3daccessType='inputOnly'/>
<field name='coordinates_changedtype='SFVec3daccessType='outputOnly'/>
<field name='extrudetype='SFBoolaccessType='initializeOnly'/>
<field name='tessellatetype='SFBoolaccessType='initializeOnly'/>
<IS>
<connect nodeField='altitudeModeprotoField='altitudeMode'/>
<connect nodeField='coordinatesprotoField='coordinates'/>
<connect nodeField='set_coordinatesprotoField='set_coordinates'/>
<connect nodeField='coordinates_changedprotoField='coordinates_changed'/>
<connect nodeField='extrudeprotoField='extrude'/>
<connect nodeField='tessellateprotoField='tessellate'/>
</IS>
<![CDATA[
          
ecmascript:

function initialize ()
{
	if  (altitudeMode == '') altitudeMode = 'clampToGround';
	if ((altitudeMode != 'clampToGround') &&
	    (altitudeMode != 'relativeToGround') &&
	    (altitudeMode != 'absolute'))
	{
		warningString = '[Point';
		if (id != '') warningString += ' ' + id;
		warningString += '] illegal value ';
		warningString += 'altitudeMode=' + altitudeMode;
		Browser.println (warningString);
	}
}

function set_coordinates (value)
{
	coordinates = value;
	coordinates_changed = value;
}

// TODO: how to handle extrude, tessellate

        
]]>
</Script>
<WorldInfo>
<IS>
<connect nodeField='titleprotoField='id'/>
</IS>
</WorldInfo>
<Group DEF='MetadataHolderPoint'>
<IS>
<connect nodeField='metadataprotoField='metadata'/>
</IS>
</Group>
</ProtoBody>
</ProtoDeclare>
<!-- ========== Examples ========== -->
<Viewpoint description='Placemark exampleposition='0 0 4'/>
<!-- <?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='namevalue='"Simple placemark"'/>
<fieldValue name='descriptionvalue='Attached to the ground. Intelligently places itself at the height of the underlying terrain.'/>
<fieldValue name='coordinatesvalue='-122.0822035425683 37.42228990140251 0'/>
<fieldValue name='addressvalue=' "https://www.web3d.org/x3d-earth" '/>
</ProtoInstance>
</Scene>
</X3D>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- Index for DEF nodes: BehaviorScript, GeometryGroup, MetadataHolderPlaceMark, MetadataHolderPoint, PlaceMarkBalloon, PlaceMarkMaterial, PlaceMarkName, PointScript, SnippetTranslation, SwitchVisible

Index for Viewpoint node: Viewpoint_1

Index for ProtoDeclare definitions: PlaceMark, Point
-->

Event Graph ROUTE Table entries with 2 ROUTE connections total, showing X3D event-model relationships for this scene.

Each row shows an event cascade that may occur during a single timestamp interval between frame renderings, as part of the X3D execution model.

BehaviorScript
Script
visibilityChoice
SFInt32

ROUTE
event to
(1)
SwitchVisible
Switch
whichChoice
SFInt32
BehaviorScript
Script
snippetOffset
SFVec3f

ROUTE
event to
(1)
SnippetTranslation
Transform
set_translation
SFVec3f


PointScript
Script
No ROUTE connection found for output from this node.
 



ProtoInstance
PlaceMark
No ROUTE connection found for output from this node.
Contains SFNode/MFNode field with indirect access to other nodes. 


-->

<!-- Online at
https://www.web3d.org/x3d/content/examples/Basic/Geospatial/KmlPrototypesIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Basic/Geospatial/KmlPrototypes.x3d -->

<!-- Color legend: X3D terminology <X3dNode DEF='idName' field='value'/> matches XML terminology <XmlElement DEF='idName' attribute='value'/>
(Light-blue background: event-based behavior node or statement) (Grey background inside box: inserted documentation) (Magenta background: X3D Extensibility)
    <ProtoInstance name='ProtoName'> <field name='fieldName'/> </ProtoInstance> -->

to top <!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->