Beispiel #1
0
  def test_convert(self):
    from spatialdata.geocoords.CSGeo import CSGeo
    csNAD27 = CSGeo()
    csNAD27.inventory.ellipsoid = "clrk66"
    csNAD27.inventory.datumHoriz = "NAD27"
    csNAD27.inventory.datumVert = "mean sea level"
    csNAD27._configure()
    csNAD27.initialize()

    from spatialdata.geocoords.CSGeoLocalCart import CSGeoLocalCart
    csLocal = CSGeoLocalCart()
    csLocal.inventory.originLon = -100.0
    csLocal.inventory.originLat = 39.0
    from pyre.units.length import m
    csLocal.inventory.originElev = 0.01*m
    csLocal.inventory.ellipsoid = "clrk66"
    csLocal.inventory.datumHoriz = "NAD27"
    csLocal.inventory.datumVert = "mean sea level"
    csLocal._configure()
    csLocal.initialize()

    from spatialdata.geocoords.Converter import convert
    coordsXYZ = numpy.array(lonlatNAD27ElevVals)
    convert(coordsXYZ, csLocal, csNAD27)
    xyzLocalValsT = numpy.array(coordsXYZ)

    self.assertEqual(len(xyzLocalVals.shape), len(xyzLocalValsT.shape))
    for (xyz, xyzT) in zip(numpy.reshape(xyzLocalVals,-1),
                           numpy.reshape(xyzLocalValsT, -1)):
      self.assertAlmostEqual(1.0, xyz/xyzT, 6)
        
    return
Beispiel #2
0
def cs_geo():
    """Geographic lat/lon coordinates in WGS84 datum.
    """
    cs = CSGeo()
    cs.inventory.datumHoriz = "WGS84"
    cs.inventory.datumVert = "mean sea level"
    cs.inventory.spaceDim = 2
    cs._configure()
    cs.initialize()
    return cs
 def setUp(self):
   from spatialdata.geocoords.CSGeo import CSGeo
   cs = CSGeo()
   cs._configure()
   cs.initialize()
   self.cs = cs
   
   from spatialdata.geocoords.Projector import Projector
   projector = Projector()
   projector.inventory.projection = projection
   projector.inventory.units = units
   projector.inventory.projOptions = projOptions
   projector._configure()
   self.projector = projector
   return
  def setUp(self):
    from spatialdata.spatialdb.contrib.UniformVelModel import UniformVelModel
    db = UniformVelModel()
    db.inventory.label = "Uniform properties"
    db._configure()
    self._db = db

    from spatialdata.geocoords.CSGeo import CSGeo
    csQ = CSGeo()
    csQ.inventory.datumHoriz = "NAD27"
    csQ.inventory.datumVert = "mean sea level"
    csQ.inventory.ellipsoid = "clrk66"
    csQ._configure()
    csQ.initialize()
    self._csQ = csQ
    return
Beispiel #5
0
  def test_convert(self):
    from spatialdata.geocoords.CSGeo import CSGeo
    csNAD27 = CSGeo()
    csNAD27.inventory.ellipsoid = "clrk66"
    csNAD27.inventory.datumHoriz = "NAD27"
    csNAD27.inventory.datumVert = "mean sea level"
    csNAD27._configure()
    csNAD27.initialize()

    from spatialdata.geocoords.CSGeoLocalCart import CSGeoLocalCart
    csLocal = CSGeoLocalCart()
    csLocal.inventory.originLon = -100.0
    csLocal.inventory.originLat = 39.0
    from pyre.units.length import m
    csLocal.inventory.originElev = 0.01*m
    csLocal.inventory.ellipsoid = "clrk66"
    csLocal.inventory.datumHoriz = "NAD27"
    csLocal.inventory.datumVert = "mean sea level"
    csLocal._configure()
    csLocal.initialize()

    from spatialdata.geocoords.Converter import convert
    coordsXYZ = numpy.array(lonlatNAD27ElevVals)
    convert(coordsXYZ, csLocal, csNAD27)
    xyzLocalValsT = numpy.array(coordsXYZ)

    self.assertEqual(len(xyzLocalVals.shape), len(xyzLocalValsT.shape))
    for (xyz, xyzT) in zip(numpy.reshape(xyzLocalVals,-1),
                           numpy.reshape(xyzLocalValsT, -1)):
      self.assertAlmostEqual(1.0, xyz/xyzT, 6)
        
    return
Beispiel #6
0
    def test_accessors(self):
        projString = "+proj=utm +zone=11"

        cs = CSGeo()
        cs.inventory.crsString = projString
        cs.inventory.spaceDim = 2
        cs._configure()

        self.assertEqual(projString, cs.getString())
        self.assertEqual(2, cs.getSpaceDim())
Beispiel #7
0
def cs_geo():
    """Geographic lat/lon coordinates in WGS84 datum.
    """
    cs = CSGeo()
    cs.inventory.datumHoriz = "WGS84"
    cs.inventory.datumVert = "mean sea level"
    cs.inventory.spaceDim = 2
    cs._configure()
    cs.initialize()
    return cs
    def test_geo(self):
        from spatialdata.geocoords.CSGeo import CSGeo
        csNAD27 = CSGeo()
        csNAD27.inventory.crsString = "EPSG:4267"
        csNAD27.inventory.spaceDim = 2
        csNAD27._configure()

        csWGS84 = CSGeo()
        csWGS84.inventory.crsString = "EPSG:4326"
        csWGS84.inventory.spaceDim = 2
        csWGS84._configure()

        from spatialdata.geocoords.Converter import convert
        lonlat = numpy.array(lonlatNAD27)
        convert(lonlat, csWGS84, csNAD27)

        self.assertEqual(len(lonlatWGS84.shape), len(lonlat.shape))
        for (ll, llT) in zip(numpy.reshape(lonlatWGS84, -1),
                             numpy.reshape(lonlat, -1)):
            self.assertAlmostEqual(ll, llT, 4)
Beispiel #9
0
    def setUp(self):
        from spatialdata.geocoords.CSGeo import CSGeo
        cs = CSGeo()
        cs._configure()
        cs.initialize()
        self.cs = cs

        from spatialdata.geocoords.Projector import Projector
        projector = Projector()
        projector.inventory.projection = projection
        projector.inventory.units = units
        projector.inventory.projOptions = projOptions
        projector._configure()
        self.projector = projector
        return
    def setUp(self):
        from spatialdata.spatialdb.contrib.UniformVelModel import UniformVelModel
        db = UniformVelModel()
        db.inventory.label = "Uniform properties"
        db._configure()
        self._db = db

        from spatialdata.geocoords.CSGeo import CSGeo
        csQ = CSGeo()
        csQ.inventory.datumHoriz = "NAD27"
        csQ.inventory.datumVert = "mean sea level"
        csQ.inventory.ellipsoid = "clrk66"
        csQ._configure()
        csQ.initialize()
        self._csQ = csQ
        return
Beispiel #11
0
 def test_constructor(self):
     cs = CSGeo()
     cs._configure()
     self.assertEqual(3, cs.getSpaceDim())
Beispiel #12
0
  def test_initialize(self):
    from spatialdata.geocoords.CSGeo import CSGeo
    cs = CSGeo()
    cs.inventory.ellipsoid = "clrk66"
    cs.inventory.datumHoriz = "NAD27"
    cs.inventory.datumVert = "mean sea level"
    cs.inventory.units = "km"
    cs.inventory.spaceDim = 2
    cs._configure()
    cs.initialize()

    self.assertEqual("clrk66", cs.ellipsoid())
    self.assertEqual("NAD27", cs.datumHoriz())
    self.assertEqual("mean sea level", cs.datumVert())
    self.assertEqual(False, cs.isGeocentric())
    self.assertEqual(1.0e+3, cs.toMeters())
    self.assertEqual(2, cs.spaceDim())

    return
Beispiel #13
0
  def test_main(self):
    """
    Test main().
    """
    filename = "in.txt"

    from spatialdata.utils.PointsStream import PointsStream
    s = PointsStream()
    s.inventory.filename = filename
    s.inventory.numFormat = "%20.8e"
    s._configure()
    
    s.write(lonlatNAD27ElevVals)

    from spatialdata.geocoords.CSGeo import CSGeo
    csNAD27 = CSGeo()
    csNAD27.inventory.ellipsoid = "clrk66"
    csNAD27.inventory.datumHoriz = "NAD27"
    csNAD27.inventory.datumVert = "mean sea level"
    csNAD27._configure()

    from spatialdata.geocoords.CSGeoLocalCart import CSGeoLocalCart
    csLocal = CSGeoLocalCart()
    csLocal.inventory.originLon = -100.0
    csLocal.inventory.originLat = 39.0
    from pyre.units.length import m
    csLocal.inventory.originElev = 0.01*m
    csLocal.inventory.ellipsoid = "clrk66"
    csLocal.inventory.datumHoriz = "NAD27"
    csLocal.inventory.datumVert = "mean sea level"
    csLocal._configure()

    from spatialdata.utils.ChangeCoordSys import ChangeCoordSys
    converter = ChangeCoordSys()
    converter.inventory.csDest = csLocal
    converter.inventory.csSrc = csNAD27
    converter._configure()

    from spatialdata.utils.ConvertApp import ConvertApp
    reader = PointsStream()
    reader.inventory.filename = filename
    reader.inventory.numFormat = "%20.8e"
    reader._configure()

    writer = PointsStream()
    writer.inventory.filename = "out.txt"
    writer.inventory.numFormat = "%20.8e"
    writer._configure()

    app = ConvertApp()
    app.inventory.reader = reader
    app.inventory.writer = writer
    app.inventory.converter = converter
    app._configure()

    app.main()

    points = writer.read()
    self.assertEqual(len(xyzLocalVals.shape), len(points.shape))
    for dE,d in zip(xyzLocalVals.shape, points.shape):
      self.assertEqual(dE, d)
    for vE,v in zip(numpy.reshape(xyzLocalVals, -1),
                    numpy.reshape(points, -1)):
      self.assertAlmostEqual(1.0, vE/v, 6)
    return
Beispiel #14
0
    def test_initialize(self):
        from spatialdata.geocoords.CSGeo import CSGeo
        cs = CSGeo()
        cs.inventory.ellipsoid = "clrk66"
        cs.inventory.datumHoriz = "NAD27"
        cs.inventory.datumVert = "mean sea level"
        cs.inventory.units = "km"
        cs.inventory.spaceDim = 2
        cs._configure()
        cs.initialize()

        self.assertEqual("clrk66", cs.ellipsoid())
        self.assertEqual("NAD27", cs.datumHoriz())
        self.assertEqual("mean sea level", cs.datumVert())
        self.assertEqual(False, cs.isGeocentric())
        self.assertEqual(1.0e+3, cs.toMeters())
        self.assertEqual(2, cs.spaceDim())

        return
Beispiel #15
0
    def test_main(self):
        """
    Test main().
    """
        filename = "in.txt"

        from spatialdata.utils.PointsStream import PointsStream
        s = PointsStream()
        s.inventory.filename = filename
        s.inventory.numFormat = "%20.8e"
        s._configure()

        s.write(lonlatNAD27ElevVals)

        from spatialdata.geocoords.CSGeo import CSGeo
        csNAD27 = CSGeo()
        csNAD27.inventory.ellipsoid = "clrk66"
        csNAD27.inventory.datumHoriz = "NAD27"
        csNAD27.inventory.datumVert = "mean sea level"
        csNAD27._configure()

        from spatialdata.geocoords.CSGeoLocalCart import CSGeoLocalCart
        csLocal = CSGeoLocalCart()
        csLocal.inventory.originLon = -100.0
        csLocal.inventory.originLat = 39.0
        from pyre.units.length import m
        csLocal.inventory.originElev = 0.01 * m
        csLocal.inventory.ellipsoid = "clrk66"
        csLocal.inventory.datumHoriz = "NAD27"
        csLocal.inventory.datumVert = "mean sea level"
        csLocal._configure()

        from spatialdata.utils.ChangeCoordSys import ChangeCoordSys
        converter = ChangeCoordSys()
        converter.inventory.csDest = csLocal
        converter.inventory.csSrc = csNAD27
        converter._configure()

        from spatialdata.utils.ConvertApp import ConvertApp
        reader = PointsStream()
        reader.inventory.filename = filename
        reader.inventory.numFormat = "%20.8e"
        reader._configure()

        writer = PointsStream()
        writer.inventory.filename = "out.txt"
        writer.inventory.numFormat = "%20.8e"
        writer._configure()

        app = ConvertApp()
        app.inventory.reader = reader
        app.inventory.writer = writer
        app.inventory.converter = converter
        app._configure()

        app.main()

        points = writer.read()
        self.assertEqual(len(xyzLocalVals.shape), len(points.shape))
        for dE, d in zip(xyzLocalVals.shape, points.shape):
            self.assertEqual(dE, d)
        for vE, v in zip(numpy.reshape(xyzLocalVals, -1),
                         numpy.reshape(points, -1)):
            self.assertAlmostEqual(1.0, vE / v, 6)
        return