Quote from: "tommi62"@Christian/kech61: Could this be the same problem as discussed here: https://groups.google.com/d/topic/mapsf ... discussion
Thanks, thats it.
So we have to live with this issue, no real problem so far.
best regards
Christian
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuQuote from: "tommi62"@Christian/kech61: Could this be the same problem as discussed here: https://groups.google.com/d/topic/mapsf ... discussion
Quote from: "menion"Netherland map have highest concentration of items on same area compare to other countries. So at one zoom level, your phone needs to handle more data then on different areas ...
#!/usr/bin/perl -w
#
# poly2gpx.pl - convert a polygon file to GPX
#
# see http://wiki.openstreetmap.org/wiki/Osmosis/Polygon_Filter_File_Format
# for the format of the polygon files
#
# Author: Hanno Hecker <vetinari+osm@ankh-morp.org>
#
# modified for windows (direct input/output from/to file - no more hassle with pipelines)
# made code more readable, this adds some milliseonds to processing time ;-)
# by Christian Kernbeis 2012
#
# Licence: GPL v3.0
# Version: 0.4.1
#
# usage: poly2gpx.pl [filename] WITHOUT EXTENSION
# eg: poly2gpx.pl austria = OK
# poly2gpx.pl austria.poly = WRONG !!!
#
############################################################################################
use strict;
use Math::Polygon;
use Carp qw( croak );
use Getopt::Long;
my $VERSION = "0.4.1";
my $name = undef;
my $trans = undef;
my $use_name = 0;
my $polyname = shift;
my $infile = $polyname.".poly";
my $outfile = $polyname.".gpx";
my @nodes = ();
my $line;
my @infile;
my $trkseg = 0;
my $trknum = 0;
#read infile to array
open (IN,"<",$infile) || die("Could not open $infile ...");
while ($line = <IN>){
#print $line; # for testing only
push (@infile, $line);
}
close (IN);
open (out1,">",$outfile) || die("Could not open $outfile ...");
print out1 <<__END;
<?xml version='1.0' encoding='UTF-8'?>
<gpx version="1.1" generator="poly2gpx.pl v$VERSION"
xmlns="http://www.topografix.com/GPX/1/1">
<metadata>
<name></name>
<desc></desc>
<author>
<name></name>
<email domain="" id=""/>
</author>
<copyright author="">
<year></year>
<license></license>
</copyright>
</metadata>
__END
foreach $line (@infile) {
if ($line =~ /^s*!?(d+)s*$/) {
$trknum = $1;
print out1 " <trk>n",
" <trkseg>n";
$trkseg = 1;
}
elsif ($line =~ /^s*ENDs*$/) {
if ($trkseg) {
$trkseg = 0;
$trknum = 0;
print out1 " </trkseg>n </trk>n";
}
else {
if ($use_name and defined $name) {
if ($trans) {
eval $trans;
if ($@) {
warn "WARNING: transformation of $name failed: $@n";
}
}
if ($nodes[0][0] != $nodes[-1][0] and $nodes[0][1] != $nodes[-1][1]) {
push @nodes, $nodes[0];
warn "WARNING: polygon '$name' is not closed...n";
}
my $poly = Math::Polygon->new(@nodes);
my $lat_lon = eval { $poly->centroid; }; # see below
if ($@) { warn $@; } # ... not here, at the end of the file
else {
#$name = encode_entities_numeric($name);
$name =~ s/&/&/g;
$name =~ s/</</g;
$name =~ s/>/>/g;
printf out1 " <wpt lat="%.7f" lon="%.7f">n <name>%s</name>n </wpt>n",
@{ $lat_lon }, $name;
}
}
print out1 "</gpx>n";
}
}
elsif ($line =~ /^s+([-+d.Ee]+)s+([-+d.Ee]+)s*$/) {
printf out1 " <trkpt lat="%.7f" lon="%.7f"/>n", $2, $1;
push @nodes, [$2, $1]
if $use_name and $trknum == 1;
}
elsif ($line =~ /^(S+)/ and not defined $name) {
$name = $1
if $1 ne "polygon";
}
}
close (out1);
print "### DONE ###";
#!/usr/bin/perl
# script to convert a GPX file to a polygon file.
#
# written by Rodolphe Quiédeville <rodolphe@quiedeville.org>, GPL.
#
# Modified for better usability = no more ">" "|", direct file output
# so it's suitable for Windows environment and so on ....
# ensured compatibility with "GPX10" output of tracks from QuoVadis6.0
#
# by Christian Kernbeis 2012, GPL
#
# Scipt have to be started in the directory of th gpx-file !!
#
# usage: eg given file = austria.gpx
# call = gpx2poly.pl austria
# output is written to austria.poly
# + map_austria.bat = batch for creating mapsforge map with bbox parameters
use strict;
my $infile = shift;
my $poly_id = 0;
my $poly_file;
my $polybuf;
my $outbuf;
my $id=0;
my $fh;
my $line;
my $inextension = "gpx";
my $outextension = "poly";
my $infilestring = "\maps\osm_data\my_clipbounds\europe\".$infile.".".$inextension;
my $outfilestring = "\maps\osm_data\my_clipbounds\europe\".$infile.".".$outextension;
my $bboxfile = "map_".$infile.".bat";
my @latbuff;
my @lonbuff;
my $bbox;
my $min_lat;
my $max_lat;
my $min_lon;
my $max_lon;
#open file
open (fh, $infilestring) or die $!;
while($line = <fh>)
{
if ($line =~ /^s*<trkpt.*slat=["']([0-9.eE-]+)["'] lon=["']([0-9.eE-]+)["']/){
$polybuf .= sprintf "t%ft%fn", $2,$1;
push (@lonbuff, $2);
push (@latbuff, $1);
}
elsif ($line =~ /^s*<trk>/){
$polybuf = "";
$poly_id++;
}
elsif ($line =~ /^s*</trk>/){
$outbuf .= "$poly_idn$polybuf"."ENDn";
}
}
close (fh);
open (fh,">",$outfilestring) or die $!;
print fh "$infilen$outbuf"."ENDn";
close fh;
@latbuff = sort { $a <=> $b } @latbuff;
@lonbuff = sort { $a <=> $b } @lonbuff;
$min_lat = @latbuff[0] - 0.0005; #runden auf 3 stellen genau FLOOR
$min_lon = @lonbuff[0] - 0.0005;
@latbuff = reverse sort { $a <=> $b } @latbuff;
@lonbuff = reverse sort { $a <=> $b } @lonbuff;
$max_lat = @latbuff[0] + 0.0005; #runden auf 3 stellen genau CEIL
$max_lon = @lonbuff[0] + 0.0005;
$bbox=
"bbox="
.sprintf ("%.3f",$min_lat)
.","
.sprintf ("%.3f",$min_lon)
.","
.sprintf ("%.3f",$max_lat)
.","
.sprintf ("%.3f",$max_lon);
open (fh,">",$bboxfile) or die $!;
print fh "d:\maps\osmosis\bin\osmosis_e.bat --rb file=D:\maps\Mapsforge\$infile\$infile","_merged.osm.pbf --mw file=D:\maps\Mapsforge\$infile\$infile.map $bbox tag-conf-file=D:\maps\Mapsforge\tag-mapping-cycle.xml bbox-enlargement=5nexitn";
close fh;
print "$bbox";