pombreda / gmapcatcher

Automatically exported from code.google.com/p/gmapcatcher
0 stars 0 forks source link

Oziexplorer .map file generation while exporting large map picture #424

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Based on Nik4 (https://github.com/Zverik/Nik4), I suggest adding a new feature 
to make the generated large PNG files directly in Oziexplorer, by adding these 
(or similar) code lines to the maps.py file.

def prepare_ozi(minx, miny, maxx, maxy, mwidth, mheight, name):
    """Create georeferencing file for OziExplorer"""
    def deg(value, is_lon):
        degrees = math.floor(abs(value))
        minutes = (abs(value) - degrees) * 60
        return '{:4d},{:3.5F},{}'.format(int(round(degrees)), minutes, ('W' if is_lon else 'S') if value < 0 else ('E' if is_lon else 'N'))
    points = "\n".join(['Point{:02d},xy,     ,     ,in, deg,    ,        ,N,    ,        ,E, grid,   ,           ,           ,N'.format(n) for n in range(3,31)])
    return '''OziExplorer Map Data File Version 2.2
GMapCatcher-mod1
{}
1 ,Map Code,
WGS 84,WGS 84,   0.0000,   0.0000,WGS 84
Reserved 1
Reserved 2
Magnetic Variation,,,E
Map Projection,Mercator,PolyCal,No,AutoCalOnly,No,BSBUseWPX,No
Point01,xy,    0,    0,in, deg,{},{}, grid,   ,           ,           ,N
Point02,xy, {:4d}, {:4d},in, deg,{},{}, grid,   ,           ,           ,N
{}
Projection Setup,,,,,,,,,,
Map Feature = MF ; Map Comment = MC     These follow if they exist
Track File = TF      These follow if they exist
Moving Map Parameters = MM?    These follow if they exist
MM0,Yes
MMPNUM,4
MMPXY,1,0,0
'''.format(name, deg(maxy, False), deg(minx, True), mwidth - 1, mheight - 1, 
deg(miny, False), deg(maxx, True), points) \
    + "MMPXY,2,{},0\n".format(mwidth) \
    + "MMPXY,3,{},{}\n".format(mwidth, mheight) \
    + "MMPXY,4,0,{}\n".format(mheight) \
    + 'MMPLL,1,{:4.6f},{:4.6f}\n'.format(minx, maxy) \
    + 'MMPLL,2,{:4.6f},{:4.6f}\n'.format(maxx, maxy) \
    + 'MMPLL,3,{:4.6f},{:4.6f}\n'.format(maxx, miny) \
    + 'MMPLL,4,{:4.6f},{:4.6f}\n'.format(minx, miny) \
    + "MM1B,{:4.4f}\n".format((40075000/360*(maxx-minx)) / mwidth * math.cos(math.radians((maxy+miny)/2))) \
    + "MOP,Map Open Position,0,0\n" \
    + "IWH,Map Image Width/Height,{},{}\n".format(mwidth, mheight)

<HR>

with open(self.tPoint['FileName'] + '.map', 'w') as f:
        f.write(prepare_ozi(self.m['xLow'], self.m['yLow'], self.m['xHigh'], self.m['yHigh'], self.sbWidth.get_value_as_int(), self.sbHeight.get_value_as_int(), self.tPoint['FileName']))

        self.m['xLow']=lowCoord[1]
        self.m['yLow']=highCoord[0]
        self.m['xHigh']=highCoord[1]
        self.m['yHigh']=lowCoord[0]

Original issue reported on code.google.com by a7n7...@gmail.com on 11 Feb 2015 at 11:53

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by heldersepu on 12 Feb 2015 at 3:51