gns2shp (Re: Extension hacking)
Anthony Lenton
antoniolenton at gmail.com
Wed Jun 11 05:48:54 CEST 2008
On Wed, Jun 11, 2008 at 12:45 AM, Anthony Lenton
<antoniolenton at gmail.com> wrote:
> --- Extensions/gns2shp/gns2shp.py (revision 2841)
> +++ Extensions/gns2shp/gns2shp.py (working copy)
> @@ -87,30 +89,33 @@
> i = 0
> for line in gns:
> if line[0] == '#': continue
> - RC, UFI, UNI, DD_LAT, DD_LONG, DMS_LAT, DMS_LONG, UTM, \
> - JOG, FC, DSG, PC, CC1, ADM1, ADM2, DIM, CC2, NT, LC, \
> - SHORT_FORM, GENERIC, SORT_NAME, FULL_NAME, FULL_NAME_ND, \
> - MODIFY_DATE = line.split('\t')
> - RC = int(RC)
> + RC, UFI, UNI, LAT, LONG, DMS_LAT, DMS_LONG, MGRS, JOG, FC, DSG, PC, \
> + CC1, ADM1, ADM2, POP, ELEV, CC2, NT, LC, SHORT_FORM, GENERIC, \
> + SORT_NAME, FULL_NAME, FULL_NAME_ND, MODIFY_DATE = line.split('\t')
> + try: RC = int(RC)
> + except ValueError: RC = None
> UFI = int(UFI)
> UNI = int(UNI)
> - DD_LAT = float(DD_LAT)
> - DD_LONG = float(DD_LONG)
> + LAT = float(LAT)
> + LONG = float(LONG)
> try: PC = int(PC)
> - except: PC = None
> - try: DIM = int(DIM)
> - except: DIM = None
> + except ValueError: PC = None
> + try: POP = int(POP)
> + except ValueError: POP = None
> + try: ELEV = int(ELEV)
> + except ValueError: ELEV = None
> MODIFY_DATE = MODIFY_DATE[0:10] # kill trailing "\n" or "\r\n"
> - obj = shapelib.SHPObject(shapelib.SHPT_POINT, i, [[(DD_LONG, DD_LAT)]])
> + obj = shapelib.SHPObject(shapelib.SHPT_POINT, i, [[(LONG, LAT)]])
> shp.write_object(-1, obj)
> - dbf.write_record(i, { 'RC': RC, 'UFI': UFI, 'UNI': UNI, 'UTM': UTM,
> - 'JOG': JOG, 'FC': FC, 'DSG': DSG, 'PC': PC,
> - 'CC1': CC1, 'ADM1': ADM1, 'ADM2': ADM2,
> - 'DIM': DIM, 'CC2': CC2, 'NT': NT, 'LC': LC,
> - 'SHORT_FORM': SHORT_FORM, 'GENERIC': GENERIC,
> - 'SORT_NAME': SORT_NAME, 'FULL_NAME': FULL_NAME,
> - 'FULL_ND': FULL_NAME_ND,
> - 'MODIFY_DAT': MODIFY_DATE})
> +
> + vals = {'RC': RC, 'UFI': UFI, 'UNI': UNI, 'MGRS':MGRS, 'JOG': JOG,
> + 'FC': FC, 'DSG': DSG, 'PC': PC, 'CC1': CC1, 'ADM1': ADM1,
> + 'ADM2': ADM2, 'POP': POP, 'ELEV': ELEV, 'CC2': CC2, 'NT': NT,
> + 'LC': LC, 'SHORT_FORM': SHORT_FORM, 'GENERIC': GENERIC,
> + 'SORT_NAME': SORT_NAME, 'FULL_NAME': FULL_NAME,
> + 'FULL_ND': FULL_NAME_ND, 'MODIFY_DAT': MODIFY_DATE}
> + print vals
Drat! That print skipped by, I was going to remove it just before
sending the patch :-&
--
Anthony Lenton
Except - The good guys in software development
http://except.com.ar
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)