/*
 * Learning JTS Topology Suite.
 * Define a WKT Multipolygon as a String.
 * With JTS parse the string to create an instance of class Geometry.
 * Get & display the coordinates of the Geometry vertices.
 */
import org.locationtech.jts.io.WKTReader

// The boundary of some neighbourhood
def mpoly = 'MULTIPOLYGON (((-113.474414620273 53.532619638549,-113.474149921333 53.5326766290234,-113.472946053886 53.5323142744812,-113.471547877045 53.531734666565,-113.471131032224 53.5316000344577,-113.469348972575 53.5305683043618,-113.468355502211 53.5299934487168,-113.466894256721 53.5293745070249,-113.465380525942 53.5287258982499,-113.463859583533 53.5280105009262,-113.462985166342 53.5275895334826,-113.461600213623 53.5267923311929,-113.459178514586 53.5254299464657,-113.45877391475 53.5253071023775,-113.457470040523 53.5252562240721,-113.455483614007 53.5231527462616,-113.455259757532 53.5228530809426,-113.455176290853 53.5225738768347,-113.455178152495 53.5221446112375,-113.455161219525 53.5200322294366,-113.455111655009 53.5179989286082,-113.458307431783 53.517997620841,-113.461356709904 53.5180296524747,-113.464389542446 53.5180266333343,-113.467429491265 53.5180262669343,-113.470151823363 53.5180298181809,-113.471756442605 53.518032581883,-113.471760770194 53.518194568505,-113.472148719979 53.5184968384537,-113.472424609404 53.5185784886163,-113.47114183979 53.5185807486158,-113.471141777201 53.518539695862,-113.470309310255 53.5185398026257,-113.470154044506 53.5185408542632,-113.470156265661 53.5190518903017,-113.471924998624 53.5190463264587,-113.472273912788 53.5190482128515,-113.472274690185 53.5191385886594,-113.472276585131 53.5195428184115,-113.471926903943 53.5195429375202,-113.471671652217 53.519543637567,-113.471671459982 53.5195684785236,-113.471673010128 53.5201285384681,-113.472486019847 53.5201274486068,-113.472494850044 53.5219350793044,-113.473080135714 53.521934284687,-113.474595469847 53.5219317183512,-113.474596813782 53.5224050963275,-113.474760374881 53.5224051892249,-113.4748827999 53.5228796276175,-113.476106340178 53.5228778872439,-113.476114890245 53.5234973585434,-113.473093172151 53.5234863045702,-113.473094504422 53.5237459887461,-113.47324277982 53.523746708594,-113.474185139938 53.5237757485617,-113.47503601028 53.5238593982918,-113.475339930072 53.5239420883651,-113.475354079695 53.5258973185572,-113.47310682848 53.5258958115122,-113.473115978306 53.5271401710798,-113.474186664248 53.5271388760592,-113.474187514909 53.527229358496,-113.475059810004 53.5272298284815,-113.475074839851 53.5290520586658,-113.475075580109 53.5291890084853,-113.475131437471 53.5292745383863,-113.475228013467 53.529532062225,-113.475232587979 53.5301470033066,-113.476292449887 53.5301453486446,-113.476292490083 53.5301640386164,-113.47727334972 53.530342928414,-113.479140609958 53.5309584886518,-113.479444019925 53.5309583084667,-113.479445070153 53.5317160983723,-113.479293390112 53.531715388297,-113.479293920318 53.5320974786646,-113.479305330258 53.5326101686777,-113.476339600232 53.5326088683824,-113.474414620273 53.532619638549)))'

// def mpoly = ''  Fails due to NullPointerException

def geomReader = new WKTReader()
def geom = geomReader.read( mpoly )
def coords = geom.getCoordinates( )

for( coord in coords ) {
    double x = coord.getX( )
    double y = coord.getY( )
    print "[ ${y} , ${x} ] "
}
