Code Monkey home page Code Monkey logo

ruby_kml's Introduction

ruby_kml

Overview

Library for generating KML(Keyhole Markup Language) files in Ruby. Sweet if you want to place markers, overlays, and other awesome things over a google map or google earth.

Install

gem install ruby_kml

Examples

See test/kml_file_test.rb for more examples

kml = KMLFile.new
folder = KML::Folder.new(:name => 'Melbourne Stations')
[
  ["Flinders St",    -37.818078, 144.966811],
  ["Southern Cross", -37.818358, 144.952417],
].each do |name, lat, lng|
  folder.features << KML::Placemark.new(
    :name => name,
    :geometry => KML::Point.new(:coordinates => {:lat => lat, :lng => lng})
  )
end
kml.objects << folder
puts kml.render

ruby_kml's People

Contributors

aeden avatar kdonovan avatar schleyfox avatar xaviershay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ruby_kml's Issues

gem install ruby_kml - failed to build native extension -- Mac with OSX 10.9.4, ruby 1.9.3

Trying to install on my Mac with OSX 10.9.4, Ruby 1.9.3p448:

gem install ruby_kml
Building native extensions. This could take a while...
Building nokogiri using packaged libraries.
ERROR: Error installing ruby_kml:
ERROR: Failed to build gem native extension.

/Users/ltalley/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb

Building nokogiri using packaged libraries.
checking for iconv.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/ltalley/.rvm/rubies/ruby-1.9.3-p448/bin/ruby
--help
--clean
--use-system-libraries
--enable-static
--disable-static
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--enable-cross-build
--disable-cross-build
/Users/ltalley/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:381:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /Users/ltalley/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:506:intry_cpp'
from /Users/ltalley/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:931:in block in have_header' from /Users/ltalley/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:790:inblock in checking_for'
from /Users/ltalley/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:284:in block (2 levels) in postpone' from /Users/ltalley/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:254:inopen'
from /Users/ltalley/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:284:in block in postpone' from /Users/ltalley/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:254:inopen'
from /Users/ltalley/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:280:in postpone' from /Users/ltalley/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:789:inchecking_for'
from /Users/ltalley/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:930:in have_header' from extconf.rb:103:inhave_iconv?'

How to call the Script

I have no idea how this works. Where do i have to put my Code and how to I call the Function? What happens then? Creates this Code a real KML File?

Can somebody help me?

NameError: uninitialized constant KML::LookAt

When I am using look at in placemark in the following code,

require 'rubygems'
require 'ruby_kml'

kml = KMLFile.new
folder = KML::Folder.new(:name => 'Melbourne Stations')

[
  ["Flinders St",    -37.818078, 144.966811, 0.00],
  ["Southern Cross", -37.818358, 144.952417, 0.00],
].each do |name, lat, lng, alt|
  folder.features << KML::Placemark.new(
    :name => name,
    :geometry => KML::Point.new(:coordinates => {:lat => lat, :lng => lng, :alt => alt}, :altitude_mode => 'absolute'),
    :look_at => KML::LookAt.new({longitude: 144.966811, latitude: -37.818078, altitude: 0.00, range: 10, tilt: 10, heading: 5, altitude_mode: "absolute"})
  )
end

kml.objects << folder
puts kml.render

I am getting the following error,

NameError: uninitialized constant KML::LookAt
  const_missing at org/jruby/RubyModule.java:2723
         (root) at kml.rb:13
           each at org/jruby/RubyArray.java:1613
         (root) at kml.rb:9

I am using jruby-1.7.13

I might be doing it the wrong way, please guide.

kml files for tests not included

  1. Error:
    test_cdata_description(KMLFileTest):
    Errno::ENOENT: No such file or directory - test/cdata_and_snippet.kml
    /Users/jeffwilliams/dev/ruby_kml/test/kml_file_test.rb:36:in read' /Users/jeffwilliams/dev/ruby_kml/test/kml_file_test.rb:36:intest_cdata_description'

  2. Error:
    test_geometry_styles(KMLFileTest):
    Errno::ENOENT: No such file or directory - test/polygon_style.kml
    /Users/jeffwilliams/dev/ruby_kml/test/kml_file_test.rb:171:in read' /Users/jeffwilliams/dev/ruby_kml/test/kml_file_test.rb:171:intest_geometry_styles'

  3. Error:
    test_ground_overlays(KMLFileTest):
    Errno::ENOENT: No such file or directory - test/ground_overlays.kml
    /Users/jeffwilliams/dev/ruby_kml/test/kml_file_test.rb:58:in read' /Users/jeffwilliams/dev/ruby_kml/test/kml_file_test.rb:58:intest_ground_overlays'

  4. Error:
    test_paths(KMLFileTest):
    Errno::ENOENT: No such file or directory - test/paths.kml
    /Users/jeffwilliams/dev/ruby_kml/test/kml_file_test.rb:99:in read' /Users/jeffwilliams/dev/ruby_kml/test/kml_file_test.rb:99:intest_paths'

  5. Error:
    test_placemark(KMLFileTest):
    Errno::ENOENT: No such file or directory - test/simple_placemark.kml
    /Users/jeffwilliams/dev/ruby_kml/test/kml_file_test.rb:13:in read' /Users/jeffwilliams/dev/ruby_kml/test/kml_file_test.rb:13:intest_placemark'

  6. Error:
    test_polygon(KMLFileTest):
    Errno::ENOENT: No such file or directory - test/polygon.kml
    /Users/jeffwilliams/dev/ruby_kml/test/kml_file_test.rb:127:in read' /Users/jeffwilliams/dev/ruby_kml/test/kml_file_test.rb:127:intest_polygon'

  7. Error:
    test_style_map(KMLFileTest):
    Errno::ENOENT: No such file or directory - test/style_map.kml
    /Users/jeffwilliams/dev/ruby_kml/test/kml_file_test.rb:214:in read' /Users/jeffwilliams/dev/ruby_kml/test/kml_file_test.rb:214:intest_style_map'

Missing "LabelStyle"

ruby_kml can not create kml-files with styles containing a LableStyle.
LableStyle can go parallel to IconStyle according to KML docu

Setting the ID: is this a feasible feature?

The documentation on KML allows and ID-attribute: e.g.<Placemark id="ID">. The comments in e.g. the placemark.rb object file, hint at this too. It is, however, not possible to set the ID, since it gets ignored.

A quick hack is a change to Placemark#render:

    def render(xm=Builder::XmlMarkup.new(:indent => 2))
      xm.Placemark(id: self.id) {
        super
        ...
      }
    end

I've some ideas on how to refactor a little to allow the ID to be set more generic, but that is quite some work, and this project seems a bit stale. Is this a feature that would be wanted?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.