/[thuban]/branches/WIP-pyshapelib-bramz/test/postgissupport.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/test/postgissupport.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2471 by bh, Thu Dec 16 14:19:21 2004 UTC revision 2472 by bh, Thu Dec 16 15:18:57 2004 UTC
# Line 251  class PostgreSQLServer: Line 251  class PostgreSQLServer:
251               [("gid_offset", 1000)]),               [("gid_offset", 1000)]),
252              ("political", os.path.join("..", "Data", "iceland",              ("political", os.path.join("..", "Data", "iceland",
253                                               "political.shp")),                                               "political.shp")),
254              ("roads", os.path.join("..", "Data", "iceland",              ("roads_multi", os.path.join("..", "Data", "iceland",
255                                           "roads-line.shp")),                                           "roads-line.shp")),
256    
257                # same as roads-multi but using LINESTRING instead of
258                # MULTILINESTRING
259                ("roads", os.path.join("..", "Data", "iceland",
260                                             "roads-line.shp"),
261                 [("force_wkt_type", "LINESTRING")]),
262    
263              # The polygon data as a MULTIPOLYGON geometry type              # The polygon data as a MULTIPOLYGON geometry type
264              ("political_multi", os.path.join("..", "Data", "iceland",              ("political_multi", os.path.join("..", "Data", "iceland",
265                                               "political.shp"),                                               "political.shp"),
# Line 629  def coords_to_polygon(coords): Line 635  def coords_to_polygon(coords):
635          poly.append(", ".join(["%r %r" % p for p in ring]))          poly.append(", ".join(["%r %r" % p for p in ring]))
636      return "POLYGON((%s))" % "), (".join(poly)      return "POLYGON((%s))" % "), (".join(poly)
637    
638    def coords_to_linestring(coords):
639        """Return string with a LINESTRING WKT representation of coords"""
640        if len(coords) > 1:
641            raise ValueError("A LINESTRING can only have one arc")
642        return "LINESTRING(%s)" % ", ".join(["%r %r" % p for p in coords[0]])
643    
644  def coords_to_multilinestring(coords):  def coords_to_multilinestring(coords):
645      """Return string with a WKT representation of the arc in coords"""      """Return string with a MULTILINESTRING WKT representation of coords"""
646      poly = []      poly = []
647      for ring in coords:      for ring in coords:
648          poly.append(", ".join(["%r %r" % p for p in ring]))          poly.append(", ".join(["%r %r" % p for p in ring]))
# Line 645  def coords_to_multipolygon(coords): Line 657  def coords_to_multipolygon(coords):
657    
658  wkt_converter = {  wkt_converter = {
659      "POINT": coords_to_point,      "POINT": coords_to_point,
660        "LINESTRING": coords_to_linestring,
661      "MULTILINESTRING": coords_to_multilinestring,      "MULTILINESTRING": coords_to_multilinestring,
662      "POLYGON": coords_to_polygon,      "POLYGON": coords_to_polygon,
663      "MULTIPOLYGON": coords_to_multipolygon,      "MULTIPOLYGON": coords_to_multipolygon,
# Line 663  def upload_shapefile(filename, db, table Line 676  def upload_shapefile(filename, db, table
676      tablename -- The name of the table to create and into which the data      tablename -- The name of the table to create and into which the data
677                  is to be inserted                  is to be inserted
678    
679      force_wkt_type -- If given the real WKT geometry type to use instead      force_wkt_type -- If given and not None, this is used as the WKT
680                  of the default that would be chosen based on the type of                  geometry type to use instead of the default that would
681                  the shapefile                  be chosen based on the type of the shapefile
682    
683      gid_offset -- A number to add to the shapeid to get the value for      gid_offset -- A number to add to the shapeid to get the value for
684                  the gid column (default 0)                  the gid column (default 0)

Legend:
Removed from v.2471  
changed lines
  Added in v.2472

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26