Beispiel #1
0
def writeSLD(style, out=sys.stdout, format=True):
  tx = SLDTransformer()
  if format: 
    tx.setIndentation(2)

  def write(os):
    tx.transform(style._style(), os) 

  util.doOutput(write, out)
Beispiel #2
0
def writeSLD(style, out=sys.stdout, format=True):
    tx = SLDTransformer()
    if format:
        tx.setIndentation(2)

    def write(os):
        tx.transform(style._style(), os)

    util.doOutput(write, out)
Beispiel #3
0
def writeJSON(obj, output=sys.stdout):
  """
  Writes a :class:`Layer <geoscript.layer.layer.Layer>` object as GeoJSON. This 
  method also accepts a :class:`Cursor <geoscript.layer.cursor.Cursor>`. 

  *output* specifies what to write the JSON to, a file or some other output stream.

  >>> import os
  >>> from geoscript.layer import Layer
  >>> from geoscript.geom import Point
  >>> 
  >>> l = Layer()
  >>> l.add([Point(1,2)])
  >>> l.add([Point(3,4)])
  >>> 
  >>> out = file(os.devnull, 'w')
  >>> writeJSON(l, output=out)
  >>> writeJSON(l.cursor('INTERSECTS(geom, POINT (1 2))'), output=out)
  """
  
  fcol = obj._fcol if isinstance(obj,Cursor) else obj._source.getFeatures()
  return doOutput(lambda out: _fjson.writeFeatureCollection(fcol, out), output)
Beispiel #4
0
def writeJSON(obj, output=sys.stdout):
    """
  Writes a :class:`Layer <geoscript.layer.layer.Layer>` object as GeoJSON. This 
  method also accepts a :class:`Cursor <geoscript.layer.cursor.Cursor>`. 

  *output* specifies what to write the JSON to, a file or some other output stream.

  >>> import os
  >>> from geoscript.layer import Layer
  >>> from geoscript.geom import Point
  >>> 
  >>> l = Layer()
  >>> l.add([Point(1,2)])
  >>> l.add([Point(3,4)])
  >>> 
  >>> out = file(os.devnull, 'w')
  >>> writeJSON(l, output=out)
  >>> writeJSON(l.cursor('INTERSECTS(geom, POINT (1 2))'), output=out)
  """

    fcol = obj._fcol if isinstance(obj, Cursor) else obj._source.getFeatures()
    return doOutput(lambda out: _fjson.writeFeatureCollection(fcol, out),
                    output)