Logotip de l'OpenStreetMap OpenStreetMap

Updates of KPAOnline Scraper

Publicat per h4ck3rm1k3 el 8 Agost 2009 en 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.

Icona de correu electrònic Icona de Bluesky Facebook Icon Icona de LinkedIn Icona de Mastodon Icona de Telegram Icona de X

Discussió

Comentari de h4ck3rm1k3 el 8 Agost 2009 a les 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.

Comentari de h4ck3rm1k3 el 8 Agost 2009 a les 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[];

Comentari de h4ck3rm1k3 el 8 Agost 2009 a les 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

Inicia sessió per a fer un comentari