1#!/usr/bin/env ruby
2
3# Copyright 2008, Google Inc. All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are met:
7#
8#  1. Redistributions of source code must retain the above copyright notice,
9#     this list of conditions and the following disclaimer.
10#  2. Redistributions in binary form must reproduce the above copyright notice,
11#     this list of conditions and the following disclaimer in the documentation
12#     and/or other materials provided with the distribution.
13#  3. Neither the name of Google Inc. nor the names of its contributors may be
14#     used to endorse or promote products derived from this software without
15#     specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
18# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
20# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28require 'setpath'  # sets path to uninstalled kmldom module.
29
30factory = Kmldom::KmlFactory.GetFactory()
31placemark = factory.CreatePlacemark()
32
33puts "has_xxx() all return false..."
34puts "placemark.has_id(): #{placemark.has_id()}"
35puts "placemark.has_name(): #{placemark.has_name()}"
36puts "placemark.has_geometry(): #{placemark.has_geometry()}"
37
38puts "set some fields"
39placemark.set_id("id123")
40placemark.set_name("we love Ruby")
41
42puts "has_xxx() now return true"
43puts "placemark.has_id(): #{placemark.has_id()}"
44puts "placemark.has_name(): #{placemark.has_name()}"
45
46puts "get the fields we set"
47puts "placemark.id(): #{placemark.id()}"
48puts "placemark.name(): #{placemark.name()}"
49
50puts "print the KML for the placemark"
51puts Kmldom::SerializePretty(placemark)
52
53puts "clear the fields"
54placemark.clear_id()
55placemark.clear_name()
56puts "placemark.id(): #{placemark.id()}"
57puts "placemark.name(): #{placemark.name()}"
58
59# Ruby automatically cleans up placemark.
60
61