#!/usr/bin/env pytest
# -*- coding: utf-8 -*-
###############################################################################
# $Id: sigdem.py 2467022a103fc35fdb5be293312688d96df2badb 2020-05-10 17:54:37 +0200 Even Rouault $
#
# Project:  GDAL/OGR Test Suite
# Purpose:  Test Scaled Integer Gridded Elevation Model support.
# Author:   Paul Austin <paul.austin@revolsys.com>
#
###############################################################################
# Copyright (c) 2018, Paul Austin <paul.austin@revolsys.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
###############################################################################



import gdaltest

###############################################################################
# Create simple copy and check.


def test_sigdem_copy_check_prj():

    tst = gdaltest.GDALTest('SIGDEM', 'byte.tif', 1, 4672)

    prj = 'PROJCS["NAD27 / UTM zone 11N",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke_1866",6378206.4,294.9786982138982]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Meter",1]]'

    return tst.testCreateCopy(check_gt=1, check_srs=prj)

###############################################################################
# Verify writing files with non-square pixels.

def test_sigdem_non_square():

    tst = gdaltest.GDALTest('SIGDEM', 'sigdem/nonsquare_nad27_utm11.vrt', 1, 12481)

    prj = 'PROJCS["NAD27 / UTM zone 11N",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke_1866",6378206.4,294.9786982138982]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Meter",1]]'

    return tst.testCreateCopy(check_gt=1, check_srs=prj)

###############################################################################
# Test creating an in memory copy.

def test_sigdem_in_memory():

    tst = gdaltest.GDALTest('SIGDEM', 'byte.tif', 1, 4672)

    return tst.testCreateCopy(vsimem=1)


###############################################################################



