Пример #1
0
def main(basepath):
    pg_user,pg_passwd,flickrapi_key,flickrapi_secret,wteapi_key=getcredentials('/root/poab/credentials.ini')
    print 'basepath: '+basepath
    for xmlfile in os.listdir(basepath):
        if xmlfile.lower().endswith('.xml'):
            print 'xmlfile: '+xmlfile
            if parsexml(basepath,xmlfile,True) == True:
                print xmlfile+' has already been parsed'
            else:
                topic,logtext,filepath,photosetname,phototitle,num_img_xml,createdate,latitude,longitude,trk_color,xmlimglist,xmltaglist,num_img_log=parsexml(basepath,xmlfile,False)
			       # topic - topic of the log-entry
			       # logtext - content-text of the log-entry
			       # filepath - where are the files belonging to this xml-file situated 
			       # photosetname - name of the set for flickr
			       # phototitle - title of the photos for flickr
			       # xmlimglist - list of the images in the xml
			       # xmltaglist - list of the images in the xml
                imagepath_fullsize=filepath+'images/sorted/'
                imagepath_resized=filepath+'images/sorted/990/'
                try:
                    trackpath=filepath+'trackfile/'
                    for trackfile in os.listdir(trackpath):
                        print trackfile
                        if trackfile.lower().endswith('.tk1'):
                            #passes outputDir,gpx-filename and tkFileName to tk2togpx.interactive to convert the tk1 to gpx
                            if os.path.exists(trackpath+trackfile[:-3]+'gpx'): # is there already a gpx-file with this name?
                                print 'gpx-file already exists, passing'
                            else:
                                tktogpx2.interactive(trackpath,trackfile.split('.')[0]+'.gpx',trackpath+trackfile)
                        else:
    			                pass 
                except IOError:
    		           print 'No Trackfile found!'
                database=db_functions.initdatabase(pg_user,pg_passwd)
    
                infomarker_id=geo_functions.gpx2database(trackpath,wteapi_key,database,trk_color,latitude,longitude,createdate)
                #files listed in xml should be geotagged already, otherwise the hash would not match anymore, image_functions.geotag is useless therefore
                #image_functions.geotag(imagepath_fullsize,imagepath_resized,trackpath)
                hashcheck,upload2flickrpath,fullsize=image_functions.checkimghash(imagepath_fullsize,imagepath_resized,xmlimglist,num_img_xml,num_img_log)
                print 'Fullsize images found:'+str(fullsize)
                if hashcheck > 0:
                    return upload2flickrpath
                image_functions.xmlimglist2db(photosetname,xmlimglist,database)
                xmlimglist_plus_db_details=image_functions.img2flickr(upload2flickrpath,fullsize,imagepath_resized,xmlimglist,xmltaglist,photosetname,phototitle,flickrapi_key,flickrapi_secret,infomarker_id,database)
                geo_functions.add_tz_country_location(xmlimglist_plus_db_details,wteapi_key,infomarker_id,database)
                log_detail=log_functions.log2db(topic,logtext,createdate,xmlimglist_plus_db_details,num_img_xml,infomarker_id,database)
                photoset_id=image_functions.getphotosetid(photosetname,database)
                if photoset_id == 0:
                    return 'Photoset not found!!!!!'
                image_functions.logid2images(log_detail,xmlimglist,photoset_id,infomarker_id,database)
                write_svg_from_db.writesvg(database)
                fill_maxmin_latlng.getmaxminbounds(database)
                finishxml(xmlfile)
                infomarker_id=''
    return 'Everything went fine i think'
Пример #2
0
        
        
        

if __name__ == "__main__":
        parser = OptionParser()
        parser.add_option("--id", action="append", dest="flickrsetid",
                help="list of flickrsetids")



        (options, args) = parser.parse_args()

        flickrsetids=options.flickrsetid
        pg_user,pg_passwd,flickrapi_key,flickrapi_secret,wteapi_key=getcredentials('credentials.ini')
        database=db_functions.initdatabase(pg_user,pg_passwd)
        for flickrsetid in flickrsetids:
            owner,primary,count,title,description=talk2flickr.get_photosetinfo(flickrsetid)
            session=database.db_session()
            db_photosets=database.db_photosets
            query_photoset=session.query(db_photosets).filter(db_photosets.flickrsetid==flickrsetid)
            if query_photoset.count() == 1:
                for detail in query_photoset.all():
                    print 'Photoset already exists - id:' + str(detail.id) + ' details:' + str(detail)
            else:
                session.add(db_photosets(flickrsetid,owner,primary,count,title,description))
                session.commit()
            query_photoset=session.query(db_photosets).filter(db_photosets.flickrsetid==flickrsetid)
            photoset=query_photoset.one()
            print photoset
            photodetails=getphotodetails(photoset,database)
Пример #3
0
def getpolylines(date,delta):
    Session,db_log,db_comments,db_continent,db_country,db_photosets,db_imageinfo,db_track,db_trackpoint,db_timezone,db_image2tag,db_phototag=db_functions.initdatabase(pg_user,pg_passwd)
    session=Session()
    query_track=session.query(db_track).filter(and_(db_track.date > date, db_track.date < date+delta))
    for detail in query_track.all():
            gencpoly_pts=detail.gencpoly_pts
            gencpoly_levels=detail.gencpoly_levels
    return gencpoly_pts,gencpoly_levels