OpenStreetMap 标志 OpenStreetMap

Updates of KPAOnline Scraper

h4ck3rm1k3 于 2009年八月 8日 以 English 发布

I have created a new script that will scrape out the street names from the points in the KPA data.
It also updates the existing data from OSM, to avoid more merge.
Chilly asked me to please not make huge posts, so the rest of the details will be in the comments if you are interested.

电子邮件图标 Bluesky图标 Facebook图标 LinkedIn图标 Mastodon图标 Telegram图标 X图标

讨论

h4ck3rm1k32009年08月 8日 17:49 的评论

Here is my changeset.
osm.org/browse/changeset/2077242
I removed one house from sharri. Hmm. Will have to do that another time.

h4ck3rm1k32009年08月 8日 17:50 的评论

here is my new script :

scraper:

#street

#grep 'td width="189" bgcolor="#ECF5FF" class="fonteLatest"' $1;

########
# street
#td width="189" bgcolor="#ECF5FF" class="fonteLatest"
#grep -h -A1 -e 'strong\>Street' $1
# | cut -d\> -f2
grep -h -A1 -e 'Street' $1 | tail -1 | cut -d\> -f2 | cut -d\< -f1 > $1.street

## building (house number)
grep -h -A1 -e 'Building' $1 | tail -1 | cut -d\> -f2 | cut -d\< -f1 > $1.building

## GPS Grid UTM
#grep -h -A2 -e 'GPS' $1 | tail -1 | cut -d\> -f2 | cut -d\< -f1 > $1.gps
grep -h -A2 -e 'GPS' $1 | tail -1 | cut -d\< -f1 | sed -e's;/; ;g' | cs2cs -E +proj=utm +zone=34T +units=m +proj=tmerc -f "%.7f" > $1.gps

#perl ~/Desktop/maps/openstreetmapkosova/convert2osm.pl convert.txt > new.osm

converter:

use strict;

use warnings;

my $filename=shift @ARGV;

sub getval
{
my $self =shift;
my $name =shift;
open IN,$filename . ".$name" or die "no file";
my $value;
# warn "filename $filename";
while ()
{
# warn $_;
chomp;

$value = $_;
$value =~ s/\s+$//g;
}
close IN;
$self->{attrs}{$name}=$value;
}

my $obj = {};

getval $obj, "street";
getval $obj, "building";
getval $obj, "gps";

my ($umtx,$umty,$lat,$lon)=split " ",$obj->{attrs}{gps};

$obj->{lat} = $lat;
$obj->{lon} = $lon;
$obj->{umtx} = $umtx;
$obj->{umty} = $umty;
delete $obj->{attrs}{gps};
if ($filename =~ /=(.+)/)
{
$obj->{attrs}{kpaid}=$1;
}

#print q[

#my $id = -1;
my $oldnode = `grep $lat changeset.txt | grep lon`;

#warn $oldnode;

#print qq[
#
#];
#print ""

die "no old node" unless $oldnode =~ /node id/;

#$oldnode =~ s/node id/node chant/;
$oldnode =~ s/node id\=/node action="modify" id=/g;
$oldnode =~ s/\/\>/\>/g;
print $oldnode;

foreach my $k (sort keys %{$obj->{attrs}})
{
my $v= $obj->{attrs}{$k};
print "\n";
}

print "\n";

#print q[];

h4ck3rm1k32009年08月 8日 18:08 的评论

here is the shell command :

for x in resultPAmun.asp\?IS\=*PZ; do  perl ~/Desktop/maps/openstreetmapkosova/convert2.pl $x;  done > newtest2.osm

登录以留下评论