Skip to content

Instantly share code, notes, and snippets.

@cbachich
Last active August 29, 2015 14:12
Show Gist options
  • Save cbachich/2422a1f02a4ffc4dcb23 to your computer and use it in GitHub Desktop.
Save cbachich/2422a1f02a4ffc4dcb23 to your computer and use it in GitHub Desktop.
Converting an array to a Multipolygon String for RGeo
test = [[[-70, 30],[-71, 31]],[[0,0],[-180,90],[-179,75]]]=> [[[-70, 30], [-71, 31]], [[0, 0], [-180, 90], [-179, 75]]]
converted = "MULTIPOLYGON ((#{test.map { |coord| "(#{coord.map { |pair| pair.join(" ") }.join ", "})" }.join ", "}))"
MULTIPOLYGON (((-70 30, -71 31), (0 0, -180 90, -179 75)))
@cbachich
Copy link
Author

Yeah that is probably best. I'm still trying to figure out if there is a way to optimize this. Thanks for the feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment