  >>> from liblas import srs
  >>> from liblas import point
  >>> from liblas import header
  
  >>> import liblas
  >>> s = srs.SRS()
  >>> s.proj4
  ''
  >>> s.proj4 = '+proj=utm +zone=15 +datum=WGS84 +units=m +no_defs'
  >>> s.proj4 == '+proj=utm +zone=15 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs '
  True
  
  >>> s = srs.SRS()
  >>> s.set_userinput('EPSG:4326')
  True
  >>> s.proj4 == '+proj=longlat +datum=WGS84 +no_defs '
  True
  
  >>> from liblas import file
  >>> f = file.File('../test/data/1.2_3.las',mode='r')
  >>> s = f.header.srs
  >>> s.wkt == """PROJCS["NAD83 / UTM zone 15N",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.2572221010002,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4269"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-93],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","26915"]]"""
  True
  
  >>> s2 = srs.SRS()
  >>> s2.wkt = """GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]"""
  >>> p = f.read(0)
  >>> p.x
  470692.44
  >>> f.set_srs(s2)
  True
  >>> p = f.read(0)
  >>> s2.vlr_count()
  4
  >>> s2.GetVLR(0).recordlength
  64
  >>> int(round(p.x))
  -93
  >>> int(round(p.y))
  42

  >>> del f


# -93.3515625902 41.5771483954

  >>> def new_offset(old_scale, new_scale, old_offset, x):
  ...       return (new_scale*(x - old_offset) - old_scale*x)/(-1.0*old_scale)
  
  >>> utm_wkt = """PROJCS["NAD83 / UTM zone 15N",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.2572221010002,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4269"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-93],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","26915"]]"""

  >>> dd_wkt = """GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]"""
  >>> s_dd = srs.SRS()
  >>> s_dd.wkt = dd_wkt
  >>> s_utm = srs.SRS()
  >>> s_utm.wkt = utm_wkt

  >>> f = file.File('../test/data/1.2_3.las',mode='r')
  >>> dd_header = liblas.header.Header(handle=f.header.handle,copy=True)
  >>> utm_header = liblas.header.Header(handle=f.header.handle,copy=True)
  >>> del f

  >>> utm_header.offset
  [0.0, 0.0, 0.0]
  >>> utm_header.scale
  [0.01, 0.01, 0.01]
  
#  >>> new_offset(0.01, 0.0001, 0.0, 470692.44)
#  >>> utm_header.offset = [offset+1.0/0.000001 for offset in utm_header.offset]
#  >>> utm_header.offset
  [1000000.0, 1000000.0, 1000000.0]
#  >>> utm_header.scale = [0.000001,0.000001,0.000001]
  >>> utm_header.srs = s_utm
  
#  >>> dd_header.scale = [0.000001,0.000001,0.000001]
  >>> dd_header.srs = s_dd
  
  >>> f = file.File('../test/data/1.2_3.las',mode='r', header = utm_header)
  >>> f.header.data_offset
  438L
  >>> f.header.scale
  [0.01, 0.01, 0.01]
  >>> p = f.read(0)
  >>> origx, origy = p.x, p.y
  >>> origx, origy
  (470692.44, 4602888.9000000004)
  >>> f.set_srs(s_dd)
  True
  >>> p = f.read(0)

We only get truncated values because our header scale 
values are 0.01

  >>> p.x, p.y
  (-93.350000000000009, 41.579999999999998)

#real values
#  (-93.351562590199833, 41.577148395415108)
  
  

  >>> f_project = file.File('junk_srs_project.las',mode='w',header=dd_header)
 
  >>> p.header = dd_header
  >>> p.x, p.y
  (-93.350000000000009, 41.579999999999998)

  >>> dd_header.srs.proj4
  '+proj=longlat +datum=WGS84 +no_defs '
  >>> f_project.write(p);f_project.write(p);f_project.write(p)
  >>> f_project.close()
  >>> del f_project
  >>> f3 = file.File('junk_srs_project.las')
  >>> f3.header.data_offset
  789L

  >>> s_utm = srs.SRS()
  >>> s_utm.wkt = utm_wkt
  >>> p3 = f3.read(1)
  >>> int(round(p3.x)), int(round(p3.y))
  (-93, 42)
  >>> p3 = f3.read(0)
  >>> int(round(p3.x)), int(round(p3.y))
  (-93, 42)

  >>> import os
  >>> os.remove('junk_srs_project.las')


  >>> f = file.File('../test/data/srs_vertcs.las',mode='r')
  >>> s = f.header.srs
  >>> s.get_wkt_compoundok() == """COMPD_CS["unknown",PROJCS["WGS 84 / UTM zone 17N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-81],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32617"]],VERT_CS["NAVD88 height",VERT_DATUM["North American Vertical Datum 1988",2005,AUTHORITY["EPSG","5103"],EXTENSION["PROJ4_GRIDS","g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx"]],AXIS["Up",UP],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","5703"]]]"""
  True

  >>> s2 = srs.SRS()
  >>> s2.wkt = """PROJCS["WGS 84 / UTM zone 17N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-81],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32617"]]"""
  >>> s2.set_verticalcs( 5703, 'abc', 5103, 9001 )
  True
  >>> s2.get_wkt_compoundok()
  'COMPD_CS["unknown",PROJCS["WGS 84 / UTM zone 17N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-81],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32617"]],VERT_CS["NAVD88 height",VERT_DATUM["North American Vertical Datum 1988",2005,AUTHORITY["EPSG","5103"],EXTENSION["PROJ4_GRIDS","g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx"]],AXIS["Up",UP],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","5703"]]]'
