parameters: (polygon)
return_statement: return postgis_polygon
docstring: Convert polygon kml into PostGIS polygon text representation.
  
      Args:
        polygon: polygon in kml format.
      Returns:
        PostGIS polygon text representation string.
docstring_summary: Convert polygon kml into PostGIS polygon text representation.
docstring_tokens: Convert polygon kml into PostGIS polygon text representation .
function: def ConvertPolygonToPsql(polygon):
      """Convert polygon kml into PostGIS polygon text representation.
  
      Args:
        polygon: polygon in kml format.
      Returns:
        PostGIS polygon text representation string.
      """
      if not polygon:
        return ""
  
      parsed_polygon = polygon[polygon.find("<Polygon>"):
                               polygon.find("</Polygon>")].strip()
      parsed_polygon = (parsed_polygon[parsed_polygon.find("<coordinates>")
                                       + len("<coordinates>"):
                                       parsed_polygon.find("</coordinates>")])
      parsed_polygon = parsed_polygon.strip()
      coordinates = parsed_polygon.split(" ")
      if len(coordinates) < 4:
        return ""
  
      # Note: item of coordinates-list may have 2 or 3 coordinates.
      postgis_polygon = ", ".join(
          ["%s %s" % tuple(coord.split(",")[:2]) for coord in coordinates])
  
      postgis_polygon = "POLYGON((%s))" % postgis_polygon
      return postgis_polygon
function_tokens: def ConvertPolygonToPsql ( polygon ) : if not polygon : return "" parsed_polygon = polygon [ polygon . find ( "<Polygon>" ) : polygon . find ( "</Polygon>" ) ] . strip ( ) parsed_polygon = ( parsed_polygon [ parsed_polygon . find ( "<coordinates>" ) + len ( "<coordinates>" ) : parsed_polygon . find ( "</coordinates>" ) ] ) parsed_polygon = parsed_polygon . strip ( ) coordinates = parsed_polygon . split ( " " ) if len ( coordinates ) < 4 : return "" # Note: item of coordinates-list may have 2 or 3 coordinates. postgis_polygon = ", " . join ( [ "%s %s" % tuple ( coord . split ( "," ) [ : 2 ] ) for coord in coordinates ] ) postgis_polygon = "POLYGON((%s))" % postgis_polygon return postgis_polygon