Skip to content

Commit

Permalink
Split block of coords by whitespace, not by \n
Browse files Browse the repository at this point in the history
Lots of programs / tools output coordinates separated only by a space, and not by newlines.  The standard states that coordinates should not have any whitespace within it, so this change will not break things.
  • Loading branch information
sgonyea committed Feb 23, 2013
1 parent 7110b54 commit 8616dda
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/border_patrol.rb
Expand Up @@ -13,7 +13,7 @@ def self.parse_kml(string)
private
def self.parse_kml_polygon_data(string)
doc = Nokogiri::XML(string)
coordinates = doc.xpath("//coordinates").text.strip.split("\n")
coordinates = doc.xpath("//coordinates").text.strip.split(/\s+/)
points = coordinates.map do |coord|
x, y, z = coord.strip.split(',')
BorderPatrol::Point.new(x.to_f, y.to_f)
Expand Down
3 changes: 1 addition & 2 deletions spec/lib/border_patrol_spec.rb
Expand Up @@ -28,8 +28,7 @@
<tessellate>1</tessellate>
<coordinates>
-10,25,0.000000
-1,30,0.000000
10,1,0.000000
-1,30,0.000000 10,1,0.000000
0,-5,000000
-10,25,0.000000
</coordinates>
Expand Down

0 comments on commit 8616dda

Please sign in to comment.