Skip to content

Commit

Permalink
fix v.in.sos name value connection
Browse files Browse the repository at this point in the history
  • Loading branch information
pesekon2 committed Aug 7, 2017
1 parent 6ac65b2 commit bc98deb
Showing 1 changed file with 3 additions and 33 deletions.
36 changes: 3 additions & 33 deletions v.in.sos/v.in.sos.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ def main():
run_command('g.remove', 'f', type='vector',
name=options['output'])
new = VectorTopo(options['output'])
# new.open('w')

for off in options['offering'].split(','):
# TODO: Find better way than iteration (at best OWSLib upgrade)
Expand Down Expand Up @@ -198,15 +197,10 @@ def main():
sys.tracebacklimit = None
else:
sys.tracebacklimit = 0
# new.close(build=False)
# new.remove()
raise AttributeError('There is no data, could you change the time parameter, observed properties, procedures or offerings')

create_maps(parsed_obs, off, layerscount, new)
layerscount += len(parsed_obs)

#new.close()

return 0


Expand Down Expand Up @@ -300,50 +294,26 @@ def create_maps(parsed_obs, offering, layer, new):
'or recompile SQLite limits as described at '
'https://sqlite.org/limits.html'.format(len(cols)))

#new.table = new.dblinks.by_layer(i).table()
#new.table.create(cols)

if new.exist() is False:
new.open(mode='w', layer=i, tab_name=tableName, tab_cols=cols, overwrite=True)
else:
new.open(mode='rw', layer=i, tab_name=tableName, tab_cols=cols, link_name=tableName, overwrite=True)


first=True
insert = [''] * len(cols)
for a in data['features']:
insert = [None] * len(cols)
for item, value in a['properties'].iteritems():
if item != 'name':
insert[cols.index((item, 'DOUBLE'))] = value
else:
if first is False:
new.write(Point(*a['geometry']['coordinates']),
insert[1:])
insert = [''] * len(cols)
insert[cols.index((item, 'VARCHAR'))] = value
first=False

new.write(Point(*a['geometry']['coordinates']),
insert[1:])

new.write(Point(*a['geometry']['coordinates']),
insert[1:])
new.table.conn.commit()
new.close()


# insert[0] = index
# index += 1
# insert = tuple(insert)
# try:
# new.table.insert([insert], many=True)
# except OperationalError:
# raise OperationalError(
# 'You have reached maximum number of columns. You should '
# 'set an event_time with a smaller range or recompile '
# 'SQLite limits as described at '
# 'https://sqlite.org/limits.html'.format(len(cols)))

# new.table.conn.commit()

i = i+1


Expand Down

0 comments on commit bc98deb

Please sign in to comment.