def setUp(self): self.process = Georeferenzierungsprozess( mapid = 10002567, nutzerid = TEST_LOGIN, clippolygon = { 'source':'pixel', 'polygon': [[467, 923],[7281, 999],[7224, 7432],[258, 7471],[467, 923]]}, georefparams = { 'source': 'pixel', 'target': 'EPSG:4314', 'gcps': [ {'source': [467, 923], 'target': [10.6666660308838, 51.4000015258789]}, {'source': [7281, 999], 'target': [10.8333339691162, 51.4000015258789]}, {'source': [7224, 7432], 'target': [10.8333339691162, 51.2999992370605]}, {'source': [258, 7471], 'target': [10.6666660308838, 51.2999992370605]} ], "algorithm": "affine", }, timestamp = "2014-08-09 12:20:26", type = 'new', algorithm = 'affine', isactive = True, processed = False, overwrites = 0, adminvalidation = '') self.map = Map(id = 10002567, apsobjectid=90015724, apsdateiname = "df_dk_0010001_4630_1928", boundingbox = "POLYGON((10.6666660308838 51.2999992370605,10.6666660308838 51.4000015258789,10.8333339691162 51.4000015258789,10.8333339691162 51.2999992370605,10.6666660308838 51.2999992370605))", originalimage = os.path.join(TEST_DATA_DIR, "df_dk_0010001_4630_1928.tif"))
def setUp(self): # create and insert test data to database self.testData = [ Map( id = 10000023, apsobjectid=90015724, apsdateiname = "df_dk_0010001_4630_1928", boundingbox = "POLYGON((16.9999980926514 51.7999992370605,16.9999980926514 51.9000015258789,17.1666679382324 51.9000015258789,17.1666679382324 51.7999992370605,16.9999980926514 51.7999992370605))", maptype="M", originalimage = os.path.join(self.testDataDir, "df_dk_0010001_4630_1928.tif"), georefimage = os.path.join(self.testDataDir, "df_dk_0010001_4630_1928.tif"), isttransformiert = True, recommendedsrid = 4314 ), Metadata( mapid = 10000023, imagezoomify = 'http://fotothek.slub-dresden.de/zooms/df/dk/0010000/df_dk_0010001_3352_1918/ImageProperties.xml', title = '', titleshort = '', scale = '1:25000', timepublish = datetime.now(), imagejpg = 'http://fotothek.slub-dresden.de/fotos/df/dk/0010000/df_dk_0010001_2655.jpg', thumbssmall = 'http://fotothek.slub-dresden.de/thumbs/df/dk/0010000/df_dk_0010001_6817.jpg', description = 'Ars an der Mosel. - Aufn. 1880, hrsg. 1882, Aufldr. 1916. - 1:25000. - [Berlin]: Kgl. Preuss. Landesaufnahme, 1916. - 1 Kt.', technic = 'Lithografie & Umdruck', type = 'Druckgraphik' ) ] self.georefProcess = Georeferenzierungsprozess( mapid = 10000023, messtischblattid = 90015724, nutzerid = self.user, clipparameter = {'source': 'pixel', 'target': 'EPSG:4314', 'gcps': [\ {'source': [467, 923], 'target': [10.6666660308838, 51.4000015258789]}, \ {'source': [7281, 999], 'target': [10.8333339691162, 51.4000015258789]}, \ {'source': [7224, 7432], 'target': [10.8333339691162, 51.2999992370605]},\ {'source': [258, 7471], 'target': [10.6666660308838, 51.2999992370605]}]}, georefparams = {'source': 'pixel', 'target': 'EPSG:4314', 'gcps': [\ {'source': [467, 923], 'target': [10.6666660308838, 51.4000015258789]}, \ {'source': [7281, 999], 'target': [10.8333339691162, 51.4000015258789]}, \ {'source': [7224, 7432], 'target': [10.8333339691162, 51.2999992370605]},\ {'source': [258, 7471], 'target': [10.6666660308838, 51.2999992370605]}]}, clippolygon = {'source': 'pixel', 'polygon': [[7813, 7517], [1652, 7523], [1677, 1666], [7830, 1661], [7813, 7517]]}, timestamp = "2014-08-09 12:20:26", type = 'update', isactive = False, processed = False, overwrites = 0, adminvalidation = '' ) try: for obj in self.testData: self.dbsession.add(obj) self.dbsession.flush() except Exception: raise
def testGetProcessWithTwoParam(self): print "--------------------------------------------------------------------------------------------" print "Testing correct working of georeferenceGetProcess for an objectid/georeferenceid for a existing process ..." # First test if it correctly response in case of existing georef process # Create dummy process georefProc = Georeferenzierungsprozess( mapid=10000023, messtischblattid=90015724, nutzerid=self.user, georefparams=ast.literal_eval( "{'new': { 'source': 'pixel', 'target': 'EPSG:4314',\ 'gcps': [{'source': [8681, 1013], 'target': [8.50000095367432, 54.7000007629395]},\ {'source': [8576, 7372], 'target': [8.50000095367432, 54.5999984741211]},\ {'source': [2358, 7260], 'target': [8.33333301544189, 54.5999984741211]},\ {'source': [2465, 888], 'target': [8.33333301544189, 54.7000007629395]}], 'algorithm':'affine'},\ 'remove': {'source': 'pixel', 'target': 'EPSG:4314', 'gcps': [\ {'source': [483, 7227], 'target': [8.33333301544189, 54.5999984741211]}, {'source': [464, 840], 'target': [8.33333301544189, 54.7000007629395]}]}}" ), clip= "POLYGON((16.9999980926514 51.7999992370605,16.9999980926514 51.9000015258789,17.1666679382324 51.9000015258789,17.1666679382324 51.7999992370605,16.9999980926514 51.7999992370605))", timestamp="2014-08-09 12:20:26", type='new', isactive=True, processed=True, overwrites=0, adminvalidation='') self.dbsession.add(georefProc) self.dbsession.flush() # object id and georeferenceid are different for testing that the georeferenceid beat the objectid params = {'objectid': 'oai:de:slub-dresden:vk:id-10000023'} request = self.getPOSTRequest(params) response = getByObjectId(request) print "Response - %s" % response self.assertEqual(response['extent'], [ 16.9999980926514, 51.7999992370605, 17.1666679382324, 51.9000015258789 ], 'Wrong or missing parameter in response ...') self.assertEqual(response['objectid'], 10000023, 'Wrong or missing parameter in response ...') self.assertEqual(response['timestamp'], "2014-08-09 12:20:26", 'Wrong or missing parameter in response ...') self.assertEqual(response['georeferenceid'], georefProc.id, 'Wrong or missing parameter in response ...') self.assertEqual(response['type'], "update", 'Wrong or missing parameter in response ...') self.assertEqual( response['zoomify'], "http://fotothek.slub-dresden.de/zooms/df/dk/0010000/df_dk_0010001_3352_1918/ImageProperties.xml", 'Wrong or missing parameter in response ...') self.dbsession.delete(georefProc)
def setUp(self): self.config = testing.setUp() self.config.registry.dbmaker = self.Session # create dummy georefprocess self.notReferencedObjId = 10000023 self.dummyProcess = Georeferenzierungsprozess( mapid = 10000023, messtischblattid = 90015724, nutzerid = TEST_LOGIN, clipparameter = "{'Test':'Test'}", georefparams = "{}", timestamp = "2014-08-09 12:20:26", type = 'new', clippolygon = '', algorithm = '', isactive = True, processed = False, overwrites = 0, adminvalidation = '') self.dummyParams = { 'georeference': { 'source': 'pixel', 'target': 'EPSG:4314', 'gcps': [ {'source': [467, 923], 'target': [10.6666660308838, 51.4000015258789]}, {'source': [7281, 999], 'target': [10.8333339691162, 51.4000015258789]}, {'source': [7224, 7432], 'target': [10.8333339691162, 51.2999992370605]}, {'source': [258, 7471], 'target': [10.6666660308838, 51.2999992370605]} ] }, 'id': 10000023, "clip": { "source":"EPSG:4314", "polygon": [[10.6666660308838, 51.4000015258789],[10.8333339691162, 51.4000015258789],[10.8333339691162, 51.2999992370605], [10.6666660308838, 51.2999992370605],[10.6666660308838, 51.4000015258789]] }, "algorithm": "affine", "userid": TEST_LOGIN } # add test data self.dbsession.add(self.testData['mapObj']) self.dbsession.flush()
def setUp(self): self.config = testing.setUp() self.config.registry.dbmaker = self.Session # create dummy georefprocess self.notReferencedObjId = 10000023 self.dummyProcess = Georeferenzierungsprozess( mapid=10000023, messtischblattid=90015724, nutzerid=self.user, clipparameter="{'Test':'Test'}", georefparams="{'Test':'Test'}", timestamp="2014-08-09 12:20:26", type='new', isactive=True, processed=False, overwrites=0, adminvalidation='') self.dummyProcessUpdate = Georeferenzierungsprozess( mapid=10000023, messtischblattid=90015724, nutzerid=self.user, clipparameter= "{'new': {'source': 'pixel', 'target': 'EPSG:4314', 'gcps': [\ {'source': [467, 923], 'target': [10.6666660308838, 51.4000015258789]}, \ {'source': [7281, 999], 'target': [10.8333339691162, 51.4000015258789]}, \ {'source': [7224, 7432], 'target': [10.8333339691162, 51.2999992370605]},\ {'source': [258, 7471], 'target': [10.6666660308838, 51.2999992370605]}]},\ 'remove':{'source': 'pixel', 'target': 'EPSG:4314', 'gcps':[]}}", georefparams= "{'new': {'source': 'pixel', 'target': 'EPSG:4314', 'gcps': [\ {'source': [467, 923], 'target': [10.6666660308838, 51.4000015258789]}, \ {'source': [7281, 999], 'target': [10.8333339691162, 51.4000015258789]}, \ {'source': [7224, 7432], 'target': [10.8333339691162, 51.2999992370605]},\ {'source': [258, 7471], 'target': [10.6666660308838, 51.2999992370605]}]},\ 'remove':{'source': 'pixel', 'target': 'EPSG:4314', 'gcps':[]}}", timestamp="2014-08-09 12:20:26", type='update', isactive=False, processed=False, overwrites=0, adminvalidation='') # create and insert test data to database self.testData = [ Map(id=10000023, apsobjectid=90015724, apsdateiname="df_dk_0010001_3352_1890", boundingbox= "POLYGON((16.9999980926514 51.7999992370605,16.9999980926514 51.9000015258789,17.1666679382324 51.9000015258789,17.1666679382324 51.7999992370605,16.9999980926514 51.7999992370605))", maptype="M"), Map(id=10000024, apsobjectid=90015725, apsdateiname="df_dk_0010001_3352_18901", maptype="GL"), Metadata( mapid=10000023, imagezoomify= 'http://fotothek.slub-dresden.de/zooms/df/dk/0010000/df_dk_0010001_3352_1918/ImageProperties.xml', title='', titleshort=''), Metadata( mapid=10000024, imagezoomify= 'http://fotothek.slub-dresden.de/zooms/df/dk/0010000/df_dk_0010001_3352_1918/ImageProperties.xml', title='', titleshort='') ] try: for obj in self.testData: self.dbsession.add(obj) self.dbsession.flush() except Exception: raise
def setUp(self): self.process = Georeferenzierungsprozess( mapid=10002567, nutzerid=TEST_LOGIN, clippolygon={ 'source': 'pixel', 'polygon': [[467, 923], [7281, 999], [7224, 7432], [258, 7471], [467, 923]] }, georefparams={ 'source': 'pixel', 'target': 'EPSG:4314', 'gcps': [{ 'source': [467, 923], 'target': [10.6666660308838, 51.4000015258789] }, { 'source': [7281, 999], 'target': [10.8333339691162, 51.4000015258789] }, { 'source': [7224, 7432], 'target': [10.8333339691162, 51.2999992370605] }, { 'source': [258, 7471], 'target': [10.6666660308838, 51.2999992370605] }], "algorithm": "affine", }, timestamp="2014-08-09 12:20:26", type='new', algorithm='affine', isactive=True, processed=False, overwrites=0, adminvalidation='') self.map = Map( id=10002567, apsobjectid=90015724, apsdateiname="df_dk_0010001_4630_1928", boundingbox= "POLYGON((10.6666660308838 51.2999992370605,10.6666660308838 51.4000015258789,10.8333339691162 51.4000015258789,10.8333339691162 51.2999992370605,10.6666660308838 51.2999992370605))", originalimage=os.path.join(TEST_DATA_DIR, "df_dk_0010001_4630_1928.tif")) self.metadata = Metadata( mapid=10002567, imagezoomify= 'http://fotothek.slub-dresden.de/zooms/df/dk/0010000/df_dk_0010001_3352_1918/ImageProperties.xml', title='', titleshort='', scale='1:25000', timepublish=datetime.now(), imagejpg= 'http://fotothek.slub-dresden.de/fotos/df/dk/0010000/df_dk_0010001_2655.jpg', thumbssmall= 'http://fotothek.slub-dresden.de/thumbs/df/dk/0010000/df_dk_0010001_6817.jpg', description= 'Ars an der Mosel. - Aufn. 1880, hrsg. 1882, Aufldr. 1916. - 1:25000. - [Berlin]: Kgl. Preuss. Landesaufnahme, 1916. - 1 Kt.', technic='Lithografie & Umdruck', type='Druckgraphik') try: self.dbsession.add(self.metadata) self.dbsession.add(self.map) self.dbsession.flush() except Exception: raise
def georeferenceConfirm(request): """ The function persistent saves a georeference confirmation request :type request: pyramid.request :return: dict :raise: HTTPBadRequest :raise: HTTPInternalServerError """ LOGGER.info('Receive georeference validation request with parameters: %s' % request.json_body) try: # extract validation data LOGGER.debug('Parse request params ...') requestData = parseGeoreferenceParamsFromRequest(request) # in case of type new, # check if there already exist an actual georeference process for this object with this type if requestData[ 'type'] == 'new' and Georeferenzierungsprozess.isGeoreferenced( requestData['mapObj'].id, request.db): msg = 'There exists already an active georeference process for this map id. It is therefore not possible to save a georeference process of type "new".' LOGGER.debug(msg) georeferenceid = Georeferenzierungsprozess.getActualGeoreferenceProcessForMapId( requestData['mapObj'].id, request.db).id return {'text': msg, 'georeferenceid': georeferenceid} LOGGER.debug('Save georeference parameter in datase ...') timestamp = convertTimestampToPostgisString(datetime.now()) georefParam = str(convertUnicodeDictToUtf(requestData['georeference'])) overwrites = requestData[ 'overwrites'] if 'overwrites' in requestData else 0 georefProcess = Georeferenzierungsprozess( messtischblattid=requestData['mapObj'].apsobjectid, nutzerid=requestData['userid'], georefparams=ast.literal_eval(georefParam), timestamp=timestamp, isactive=False, type=requestData['type'], overwrites=overwrites, adminvalidation='', processed=False, mapid=requestData['mapObj'].id, algorithm=requestData['georeference']['algorithm']) request.db.add(georefProcess) request.db.flush() # add polygon if 'clip' in requestData: clipParam = convertUnicodeDictToUtf(requestData['clip']) polygonAsString = convertListToPostgisString( clipParam['polygon'], 'POLYGON') georefProcess.setClip(polygonAsString, stripSRIDFromEPSG(clipParam['source']), request.db) LOGGER.debug('Create response ...') # @TODO has to be updated points = int(len(requestData['georeference']['gcps']) * 5) return { 'text': 'Georeference result saved. It will soon be ready for use.', 'georeferenceid': georefProcess.id, 'points': points } except ParameterException as e: LOGGER.error(e) LOGGER.error(traceback.format_exc()) raise HTTPBadRequest(ERROR_MSG) except Exception as e: LOGGER.error(e) LOGGER.error(traceback.format_exc()) raise HTTPInternalServerError(ERROR_MSG)