Skip to content

Commit

Permalink
4ALAMO à partir de fichiers
Browse files Browse the repository at this point in the history
4ALAMO accepte en source de donnée un dossier, dans lequel les GeoJSON et le GeoBUF seront utilisé en entrée de tippecanoe. Avec cette source de données, pas besoin de définir de zone (celle des données sera utilisée), et on est forcément sur un seul script.
  • Loading branch information
Dolite committed Apr 27, 2022
1 parent 34fa1f3 commit 61d2874
Show file tree
Hide file tree
Showing 18 changed files with 581 additions and 210 deletions.
20 changes: 15 additions & 5 deletions bin/4alamo.pl
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ sub doIt {
return FALSE;
}
my $sourceType = $objSource->getType();
if ($sourceType ne "POSTGRESQL") {
ERROR("4ALAMO generation accept only POSTGRESQL sources");
if ($sourceType ne "POSTGRESQL" && $sourceType ne "VECTORS") {
ERROR("4ALAMO generation accept only POSTGRESQL or VECTORS sources");
return FALSE;
}
push(@{$this{loaded}->{sources}}, $objSource);
Expand Down Expand Up @@ -505,6 +505,18 @@ sub doIt {
my $globalTopOrder = undef;
my $globalBottomOrder = undef;
foreach my $s (@{$this{loaded}->{sources}}) {

if ($s->getType() eq "VECTORS") {
if (uc($tms->getSRS()) ne uc($s->getSRS())) {
ERROR(sprintf "If one source is typed VECTORS, its SRS have to be the used TMS one (%s <> %s)", uc($tms->getSRS()), uc($s->getSRS()));
return FALSE;
}

$params->{process}->{parallelization} = 1;
INFO("With a VECTORS source, parallelization have to be 1");
}


my $topID = $s->getTopID();
my $topOrder = $tms->getOrderfromID($topID);
if (! defined $topOrder) {
Expand Down Expand Up @@ -551,7 +563,7 @@ sub doIt {

my $ID = $tms->getIDfromOrder($order);

if (! $this{loaded}->{output_pyramid}->addLevel($ID, $s->getSourceDatabase()) ) {
if (! $this{loaded}->{output_pyramid}->addLevel($ID, $s->getSource()) ) {
ERROR("Cannot add level $ID");
return FALSE;
}
Expand Down Expand Up @@ -599,8 +611,6 @@ sub doIt {
ERROR("Can not compute forest !");
return FALSE;
}

DEBUG(sprintf "FOREST (debug export) = %s", $this{loaded}->{forest}->exportForDebug());

#######################
# Écrire le script principal
Expand Down
Empty file modified bin/4head.pl
100644 → 100755
Empty file.
4 changes: 1 addition & 3 deletions bin/be4.pl
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ sub doIt {

my $bottomID = $s->getBottomID();
if ($bottomID eq "<AUTO>") {
$bottomID = $tms->getBestLevelID($s->getSourceImage()->getBestResImage());
$bottomID = $tms->getBestLevelID($s->getSource()->getBestResImage());
if (! defined $bottomID) {
ERROR(sprintf "Cannot auto detect the bottom level from image source best resolution");
return FALSE;
Expand Down Expand Up @@ -676,8 +676,6 @@ sub doIt {
ERROR("Can not compute forest !");
return FALSE;
}

DEBUG(sprintf "FOREST (debug export) = %s", $this{loaded}->{forest}->exportForDebug());

#######################
# Écrire le script principal
Expand Down
6 changes: 3 additions & 3 deletions bin/joincache.pl
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ sub load {
push(@{$this{loaded}->{sources}}, $objSource);

if (! defined $refPyramid) {
$refPyramid = $objSource->getSourcePyramid()->getPyramids()->[0];
} elsif ($refPyramid->checkCompatibility($objSource->getSourcePyramid()->[0]) == 0) {
$refPyramid = $objSource->getSource()->getPyramids()->[0];
} elsif ($refPyramid->checkCompatibility($objSource->getSource()->getPyramids()->[0]) == 0) {
ERROR("Different PYRAMIDS sources have to be consistent");
return FALSE;
}
Expand Down Expand Up @@ -394,7 +394,7 @@ sub load {

my $tms = $this{loaded}->{output_pyramid}->getTileMatrixSet();
foreach my $s (@{$this{loaded}->{sources}}) {
my $pyramids = $s->getSourcePyramid()->getPyramids();
my $pyramids = $s->getSource()->getPyramids();

my $topID = $s->getTopID();
my $topOrder = $tms->getOrderfromID($topID);
Expand Down
Empty file modified bin/pyr2pyr.pl
100644 → 100755
Empty file.
3 changes: 3 additions & 0 deletions lib/ROK4/BE4/Shell.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,9 @@ sub getScriptInitialization {
}
$string .= "MNT_CONF_DIR=$MNTCONFDIR\n";

$string .= sprintf "TILES_PER_WIDTH=%s\n", $pyramid->getTilesPerWidth();
$string .= sprintf "TILES_PER_HEIGHT=%s\n", $pyramid->getTilesPerHeight();

$string .= sprintf "WORK2CACHE_MASK_OPTIONS=\"-c zip -t %s %s\"\n", $pyramid->getTileMatrixSet()->getTileWidth(), $pyramid->getTileMatrixSet()->getTileHeight();

$string .= sprintf "WORK2CACHE_IMAGE_OPTIONS=\"-c %s -t %s %s -s %s -b %s -a %s\"\n",
Expand Down
21 changes: 20 additions & 1 deletion lib/ROK4/FOURALAMO/4alamo.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,25 @@
"minItems": 1
}
}
},{
"type": "object",
"description": "Fichiers vecteurs comme source de données",
"required": ["type", "directory", "srs"],
"properties": {
"type": {
"type": "string",
"description": "Type de source",
"enum": ["VECTORS"]
},
"srs": {
"type": "string",
"description": "Système de coordonnées des données"
},
"directory": {
"type": "string",
"description": "Dossier contenant les fichiers vecteurs, potentiellement dans une sous arborescence"
}
}
}]
}
}
Expand Down Expand Up @@ -304,7 +323,7 @@
},
"parallelization": {
"type": "integer",
"description": "Niveau de parallélisation, défini le nombre de scripts de génération exécutables en parallèle",
"description": "Niveau de parallélisation, défini le nombre de scripts de génération exécutables en parallèle. Si une source VECTORS est présente, le niveau de parallélisation sera forcé à 1.",
"minimum": 1
}
}
Expand Down
14 changes: 10 additions & 4 deletions lib/ROK4/FOURALAMO/Node.pm
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,10 @@ sub makeJsons {
my $this = shift;
my $datasource = shift;

my $dburl = $datasource->getSourceDatabase()->getSourceDatabaseInfos();
my $dburl = $datasource->getSource()->getInfos();
my $srcSrs = $datasource->getSRS();

my @tables = $datasource->getSourceDatabase()->getSqlExports();
my @tables = $datasource->getSource()->getSqlExports();

my @tmp = $this->getBBox(TRUE);
if ($this->getLevel() eq "0") {
Expand Down Expand Up @@ -411,8 +411,14 @@ Returns:
sub makeTiles {
my $this = shift;
my $datasource = shift;

$this->{script}->write(sprintf "MakeTiles %s %s \"%s\"\n", $this->getGraph()->getTopID(), $this->getGraph()->getBottomID(), $datasource->getSourceDatabase()->getTippecanoeOptions());

# ${TMP_DIR}/jsons/*.json
my $sources = '${TMP_DIR}/jsons/*.json';
if ($datasource->getType() eq "VECTORS") {
$sources = $datasource->getSource()->getPathsList();
}

$this->{script}->write(sprintf "MakeTiles \"$sources\" %s %s \"%s\"\n", $this->getGraph()->getTopID(), $this->getGraph()->getBottomID(), $datasource->getTippecanoeOptions());

return TRUE;
}
Expand Down
120 changes: 101 additions & 19 deletions lib/ROK4/FOURALAMO/Shell.pm
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,18 @@ my $MAKETILES = <<'FUNCTION';
mkdir -p ${TMP_DIR}/pbfs/
MakeTiles () {
local top_level=$1
local bottom_level=$2
local generalization_options=$3
local sources=$1
local top_level=$2
local bottom_level=$3
local generalization_options=$4
if [[ "${work}" == "0" ]]; then
return
fi
rm -r ${TMP_DIR}/pbfs/*
tippecanoe ${TIPPECANOE_OPTIONS} $generalization_options --base-zoom ${top_level} --full-detail 0 -Z ${top_level} -z ${bottom_level} -e ${TMP_DIR}/pbfs/ ${TMP_DIR}/jsons/*.json
tippecanoe ${TIPPECANOE_OPTIONS} $generalization_options --base-zoom ${top_level} --full-detail 10 -Z ${top_level} -z ${bottom_level} -e ${TMP_DIR}/pbfs/ $sources
if [ $? != 0 ] ; then echo $0; fi
rm ${TMP_DIR}/jsons/*.json
Expand Down Expand Up @@ -193,9 +194,30 @@ PushSlab () {
return
fi
pbf2cache ${PBF2CACHE_OPTIONS} -r ${TMP_DIR}/pbfs/${level} -ultile $ulcol $ulrow -bucket ${PYR_BUCKET} ${PYR_PREFIX}/$imgName
if [ $? != 0 ] ; then echo $0 : Erreur a la ligne $(( $LINENO - 1)) >&2 ; exit 1; fi
echo "0/$imgName" >> ${TMP_LIST_FILE}
local empty=1
let colmax=$ulcol+$TILES_PER_WIDTH-1
let rowmax=$ulrow+$TILES_PER_HEIGHT-1
for (( c=$ulcol; c<=$colmax; c++ )); do
for (( r=$ulrow; r<=$rowmax; r++ )); do
if [[ -e ${TMP_DIR}/pbfs/${level}/$c/$r.pbf ]]; then
empty=0
break
fi
done
if [[ "${empty}" = "0" ]]; then
break
fi
done
if [[ "${empty}" = "0" ]]; then
pbf2cache -t ${TILES_PER_WIDTH} ${TILES_PER_HEIGHT} -r ${TMP_DIR}/pbfs/${level} -ultile $ulcol $ulrow -bucket ${PYR_BUCKET} ${PYR_PREFIX}/$imgName
if [ $? != 0 ] ; then echo $0 : Erreur a la ligne $(( $LINENO - 1)) >&2 ; exit 1; fi
echo "0/$imgName" >> ${TMP_LIST_FILE}
fi
print_prog
}
FUNCTION

Expand All @@ -216,9 +238,30 @@ PushSlab () {
return
fi
pbf2cache ${PBF2CACHE_OPTIONS} -r ${TMP_DIR}/pbfs/${level} -ultile $ulcol $ulrow -container ${PYR_CONTAINER} ${PYR_PREFIX}/$imgName
if [ $? != 0 ] ; then echo $0 : Erreur a la ligne $(( $LINENO - 1)) >&2 ; exit 1; fi
echo "0/$imgName" >> ${TMP_LIST_FILE}
local empty=1
let colmax=$ulcol+$TILES_PER_WIDTH-1
let rowmax=$ulrow+$TILES_PER_HEIGHT-1
for (( c=$ulcol; c<=$colmax; c++ )); do
for (( r=$ulrow; r<=$rowmax; r++ )); do
if [[ -e ${TMP_DIR}/pbfs/${level}/$c/$r.pbf ]]; then
empty=0
break
fi
done
if [[ "${empty}" = "0" ]]; then
break
fi
done
if [[ "${empty}" = "0" ]]; then
pbf2cache -t ${TILES_PER_WIDTH} ${TILES_PER_HEIGHT} -r ${TMP_DIR}/pbfs/${level} -ultile $ulcol $ulrow -container ${PYR_CONTAINER} ${PYR_PREFIX}/$imgName
if [ $? != 0 ] ; then echo $0 : Erreur a la ligne $(( $LINENO - 1)) >&2 ; exit 1; fi
echo "0/$imgName" >> ${TMP_LIST_FILE}
fi
print_prog
}
FUNCTION

Expand All @@ -240,9 +283,28 @@ PushSlab () {
return
fi
pbf2cache ${PBF2CACHE_OPTIONS} -r ${TMP_DIR}/pbfs/${level} -ultile $ulcol $ulrow -pool ${PYR_POOL} ${PYR_PREFIX}/$imgName
if [ $? != 0 ] ; then echo $0 : Erreur a la ligne $(( $LINENO - 1)) >&2 ; exit 1; fi
echo "0/$imgName" >> ${TMP_LIST_FILE}
local empty=1
let colmax=$ulcol+$TILES_PER_WIDTH-1
let rowmax=$ulrow+$TILES_PER_HEIGHT-1
for (( c=$ulcol; c<=$colmax; c++ )); do
for (( r=$ulrow; r<=$rowmax; r++ )); do
if [[ -e ${TMP_DIR}/pbfs/${level}/$c/$r.pbf ]]; then
empty=0
break
fi
done
if [[ "${empty}" = "0" ]]; then
break
fi
done
if [[ "${empty}" = "0" ]]; then
pbf2cache -t ${TILES_PER_WIDTH} ${TILES_PER_HEIGHT} -r ${TMP_DIR}/pbfs/${level} -ultile $ulcol $ulrow -pool ${PYR_POOL} ${PYR_PREFIX}/$imgName
if [ $? != 0 ] ; then echo $0 : Erreur a la ligne $(( $LINENO - 1)) >&2 ; exit 1; fi
echo "0/$imgName" >> ${TMP_LIST_FILE}
fi
print_prog
}
Expand All @@ -267,12 +329,31 @@ PushSlab () {
return
fi
local dir=`dirname ${PYR_DIR}/$imgName`
if [ ! -d $dir ] ; then mkdir -p $dir ; fi
local empty=1
pbf2cache ${PBF2CACHE_OPTIONS} -r ${TMP_DIR}/pbfs/${level} -ultile $ulcol $ulrow ${PYR_DIR}/$imgName
if [ $? != 0 ] ; then echo $0 : Erreur a la ligne $(( $LINENO - 1)) >&2 ; exit 1; fi
echo "0/$imgName" >> ${TMP_LIST_FILE}
let colmax=$ulcol+$TILES_PER_WIDTH-1
let rowmax=$ulrow+$TILES_PER_HEIGHT-1
for (( c=$ulcol; c<=$colmax; c++ )); do
for (( r=$ulrow; r<=$rowmax; r++ )); do
if [[ -e ${TMP_DIR}/pbfs/${level}/$c/$r.pbf ]]; then
empty=0
break
fi
done
if [[ "${empty}" = "0" ]]; then
break
fi
done
if [[ "${empty}" = "0" ]]; then
local dir=`dirname ${PYR_DIR}/$imgName`
if [ ! -d $dir ] ; then mkdir -p $dir ; fi
pbf2cache -t ${TILES_PER_WIDTH} ${TILES_PER_HEIGHT} -r ${TMP_DIR}/pbfs/${level} -ultile $ulcol $ulrow ${PYR_DIR}/$imgName
if [ $? != 0 ] ; then echo $0 : Erreur a la ligne $(( $LINENO - 1)) >&2 ; exit 1; fi
echo "0/$imgName" >> ${TMP_LIST_FILE}
fi
print_prog
}
Expand Down Expand Up @@ -454,7 +535,8 @@ sub getScriptInitialization {

$string .= sprintf "TIPPECANOE_OPTIONS=\"--no-progress-indicator --no-tile-compression -s %s\"\n", $pyramid->getTileMatrixSet()->getSRS();

$string .= sprintf "PBF2CACHE_OPTIONS=\"-t %s %s\"\n", $pyramid->getTilesPerWidth(), $pyramid->getTilesPerHeight();
$string .= sprintf "TILES_PER_WIDTH=%s\n", $pyramid->getTilesPerWidth();
$string .= sprintf "TILES_PER_HEIGHT=%s\n", $pyramid->getTilesPerHeight();

if ($pyramid->getStorageType() eq "FILE") {
$string .= sprintf "PYR_DIR=%s\n", $pyramid->getDataRoot();
Expand Down
31 changes: 2 additions & 29 deletions lib/ROK4/PREGENERATION/Forest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ sub _load {

my $scriptInit = undef;
if (ref ($this->{pyramid}) eq "ROK4::Core::PyramidRaster") {
# Si on génère une pyramide raster, c'est que nous utilisons l'outil BE4, et des variables sont à initialiser dans la librairie des commandes Shell pour BE4
# Si on génère une pyramide raster, c'est que nous utilisons l'outil BE4, et des variables sont à
# initialiser dans la librairie des commandes Shell pour BE4

if (! ROK4::BE4::Shell::setGlobals($params)) {
ERROR ("Impossible d'initialiser la librairie des commandes Shell pour BE4");
Expand Down Expand Up @@ -327,34 +328,6 @@ sub getScripts {
return $this->{scripts};
}

####################################################################################################
# Group: Export methods #
####################################################################################################

=begin nd
Function: exportForDebug
Returns all informations about the forest. Useful for debug.
Example:
(start code)
(end code)
=cut
sub exportForDebug {
my $this = shift ;

my $export = "";

$export .= sprintf "\n Object ROK4::PREGENERATION::Forest :\n";

$export .= "\t Graph :\n";
$export .= sprintf "\t Number of graphs in the forest : %s\n", scalar @{$this->{graphs}};

$export .= "\t Scripts :\n";
$export .= sprintf "\t Parallelization level : %s\n", $this->{splitNumber};

return $export;
}

1;
__END__
Loading

0 comments on commit 61d2874

Please sign in to comment.