<s> def point ( c ) : <EOL> return "<STR_LIT>" . format ( c [ <NUM_LIT:0> ] , c [ <NUM_LIT:1> ] ) <EOL> def multiPoint ( coordinates ) : <EOL> values = [ ] <EOL> for coord in coordinates : <EOL> values . append ( "<STR_LIT>" . format ( point ( coord ) ) ) <EOL> return "<STR_LIT:U+002CU+0020>" . join ( values ) <EOL> def linearRing ( coordinates ) : <EOL> values = [ ] <EOL> for coord in coordinates : <EOL> values . append ( point ( coord ) ) <EOL> return "<STR_LIT:U+002CU+0020>" . join ( values ) <EOL> def multiRing ( coordinates ) : <EOL> values = [ ] <EOL> for lineString in coordinates : <EOL> values . append ( "<STR_LIT>" . format ( linearRing ( lineString ) ) ) <EOL> return "<STR_LIT:U+002CU+0020>" . join ( values ) <EOL> def metaMultiRing ( coordinates ) : <EOL> values = [ ] <EOL> for lineString in coordinates : <EOL> values . append ( "<STR_LIT>" . format ( multiRing ( lineString ) ) ) <EOL> return "<STR_LIT:U+002CU+0020>" . join ( values ) <EOL> def makePoint ( c ) : <EOL> return [ "<STR_LIT>" , point ( c ) ] <EOL> def makeMultiPoint ( c ) : <EOL> return [ "<STR_LIT>" , multiPoint ( c ) ] <EOL> def makeLineString ( c ) : <EOL> return [ "<STR_LIT>" , linearRing ( c ) ] <EOL> def makeMultiLineString ( c ) : <EOL> return [ "<STR_LIT>" , multiRing ( c ) ] <EOL> def makePolygon ( c ) : <EOL> return [ "<STR_LIT>" , multiRing ( c ) ] <EOL> def makeMultiPolygon ( c ) : <EOL> return [ "<STR_LIT>" , metaMultiRing ( c ) ] <EOL> def makeCollection ( geometries ) : <EOL> values = [ ] <EOL> for geom in geometries : <EOL> [ ptrn , coords ] = parseGeo ( geom ) <EOL> values . append ( "<STR_LIT>" . format ( ptrn , coords ) ) <EOL> return [ "<STR_LIT>" , "<STR_LIT:U+002CU+0020>" . join ( values ) ] <EOL> def parseGeo ( geometry ) : <EOL> if geometry [ "<STR_LIT:type>" ] == "<STR_LIT>" : <EOL> return makePoint ( geometry [ "<STR_LIT>" ] ) <EOL> elif geometry [ "<STR_LIT:type>" ] == "<STR_LIT>" : <EOL> return makeMultiPoint ( geometry [ "<STR_LIT>" ] ) <EOL> elif geometry [ "<STR_LIT:type>" ] == "<STR_LIT>" : <EOL> return makeLineString ( geometry [ "<STR_LIT>" ] ) <EOL> elif geometry [ "<STR_LIT:type>" ] == "<STR_LIT>" : <EOL> return makeMultiLineString ( geometry [ "<STR_LIT>" ] ) <EOL> elif geometry [ "<STR_LIT:type>" ] == "<STR_LIT>" : <EOL> return makePolygon ( geometry [ "<STR_LIT>" ] ) <EOL> elif geometry [ "<STR_LIT:type>" ] == "<STR_LIT>" : <EOL> return makeMultiPolygon ( geometry [ "<STR_LIT>" ] ) <EOL> elif geometry [ "<STR_LIT:type>" ] == "<STR_LIT>" : <EOL> return makeCollection ( geometry [ "<STR_LIT>" ] ) <EOL> def makeWKT ( geometry ) : <EOL> [ ptrn , coords ] = parseGeo ( geometry ) <EOL> return "<STR_LIT>" . format ( ptrn , coords ) <EOL> def getWKTFunc ( fun ) : <EOL> return lambda x : makeWKT ( fun ( x ) ) </s>
