Last active
August 29, 2015 14:12
-
-
Save cbachich/2422a1f02a4ffc4dcb23 to your computer and use it in GitHub Desktop.
Converting an array to a Multipolygon String for RGeo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ", "}))" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MULTIPOLYGON (((-70 30, -71 31), (0 0, -180 90, -179 75))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah that is probably best. I'm still trying to figure out if there is a way to optimize this. Thanks for the feedback.