Skip to content

Commit 4965187

Browse files
committed
Coordinate per anno 2025_NEW (PDF 2026 con settembre, ottobre e novembre 2025) e modifiche al codice necessarie
1 parent b242040 commit 4965187

5 files changed

Lines changed: 17 additions & 15 deletions

File tree

PDFs/2025/CHIERI3B_2025.pdf

-558 KB
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#left,top,with,height,label,id,regexp,collection_time,all_day_event,days_offest,hours_offset,mins_offset
2+
21.07,162.48,155.27,311.49,ottobre,10,(^\d*) (\S*) (.*$),07:00,true,0,0,0
3+
181.81,162.48,155.27,311.49,novembre,11,(^\d*) (\S*) (.*$),07:00,true,0,0,0
4+
344.91,162.48,155.27,311.49,dicembre,12,(^\d*) (\S*) (.*$),07:00,true,0,0,0

run_me.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
declare -a zones=($(cat comuni.txt | tr '[a-z]' '[A-Z]' | sed 's/ //g'))
44

55
# Mantenere gli ultimi due anni (quello nuovo e quello precedente)
66
declare -a years=(
7-
"2024"
8-
"2025"
7+
["2025"]="2025"
8+
["2025_NEW"]="2026"
99
)
1010

1111
for year in "${years[@]}"
@@ -23,12 +23,12 @@ do
2323
do
2424
mkdir -p PDFs/$year
2525
if [ ! -s "PDFs/${year}/${zone}_${year}.*" ]; then
26-
echo "Downloading from https://www.ccs.to.it/flex/Extensions/appCCSCalendario/pages/serveDownload.php?a=${year}&f=${zone}.pdf&t=raccolta"
26+
echo "Downloading from https://www.ccs.to.it/flex/Extensions/appCCSCalendario/pages/serveDownload.php?a=${years["$year"]}&f=${zone}.pdf&t=raccolta"
2727
curl -lsk --retry 5 --retry-max-time 120 --max-time 30 -o PDFs/${year}/${zone}_${year}.pdf "https://www.ccs.to.it/flex/Extensions/appCCSCalendario/pages/serveDownload.php?a=${year}&f=${zone}.pdf&t=raccolta"
2828
if [ -s PDFs/${year}/${zone}_${year}.pdf ]; then
2929
echo "PDF file PDFs/${year}/${zone}_${year}.pdf downloaded"
3030
else
31-
echo "Downloading from https://www.ccs.to.it/flex/Extensions/appCCSCalendario/pages/serveDownload.php?a=${year}&f=${zone}.PDF&t=raccolta"
31+
echo "Downloading from https://www.ccs.to.it/flex/Extensions/appCCSCalendario/pages/serveDownload.php?a=${years["$year"]}&f=${zone}.PDF&t=raccolta"
3232
curl -lsk --retry 5 --retry-max-time 120 --max-time 30 -o PDFs/${year}/${zone}_${year}.pdf "https://www.ccs.to.it/flex/Extensions/appCCSCalendario/pages/serveDownload.php?a=${year}&f=${zone}.PDF&t=raccolta"
3333
if [ -f PDFs/${year}/${zone}_${year}.pdf ]; then
3434
echo "PDF file PDFs/${year}/${zone}_${year}.PDF downloaded"
@@ -37,7 +37,7 @@ do
3737
fi
3838
if test -s "PDFs/${year}/${zone}_${year}.pdf" && test -f "coordinates/${year}/${zone}_${year}_coordinates.csv"; then
3939
echo "Processing file PDFs/${year}/${zone}_${year}.pdf using coordinates from coordinates/${year}/${zone}_${year}.csv"
40-
java -jar target/chieri-calendari-raccolta-rifiuti-1.0-SNAPSHOT-jar-with-dependencies.jar ${zone} PDFs/${year}/${zone}_${year}.pdf coordinates/${year}/${zone}_${year}_coordinates.csv ${year} CSVs/${year} ICSs/${year}
40+
java -jar target/chieri-calendari-raccolta-rifiuti-1.0-SNAPSHOT-jar-with-dependencies.jar ${zone} PDFs/${year}/${zone}_${year}.pdf coordinates/${year}/${zone}_${year}_coordinates.csv ${year//[^0-9]/} CSVs/${year} ICSs/${year}
4141
fi
4242
done
43-
done
43+
done

src/main/java/it/sunnyvale/chieriraccoltarifiuti/Main.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ public static void main(String[] args) {
4545
ICSUtils icsUtils = new ICSUtils(zone,year);
4646

4747
try {
48-
4948
for (Coordinates coordinates : coordinatesArray) {
50-
51-
5249
FileInputStream inputStream = new FileInputStream(inputPDFFilePath);
5350
byte[] pdfBytes = IOUtils.toByteArray(inputStream);
5451
PDDocument pddDoc = PDDocument.load(pdfBytes);
@@ -90,8 +87,8 @@ public static void main(String[] args) {
9087
pddDoc.close();
9188

9289
}
93-
csvUtils.toFile(outputCSVPath + System.getProperty("file.separator") + zone + "_" + year + ".csv");
94-
icsUtils.toFile(outputICSPath + System.getProperty("file.separator") + zone + "_" + year + ".ics");
90+
csvUtils.toFile(outputCSVPath + System.getProperty("file.separator") + zone + "_" + outputCSVPath.split("/")[1] + ".csv");
91+
icsUtils.toFile(outputICSPath + System.getProperty("file.separator") + zone + "_" + outputICSPath.split("/")[1] + ".ics");
9592
} catch (IOException e) {
9693
e.printStackTrace();
9794
}

src/main/java/it/sunnyvale/chieriraccoltarifiuti/utils/CoordinatesUtils.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
import java.nio.file.Path;
1010
import java.nio.file.Paths;
1111
import java.time.LocalTime;
12+
import java.util.ArrayList;
1213

1314
public class CoordinatesUtils {
1415

1516
public static Coordinates[] readCoordinatesFromCSV(String fileName) {
16-
Coordinates[] coordinatesArray = new Coordinates[12];
17+
ArrayList<Coordinates> coordinatesArrayList = new ArrayList<>();
1718
Path pathToFile = Paths.get(fileName);
1819
try (BufferedReader br = Files.newBufferedReader(pathToFile, StandardCharsets.US_ASCII)) {
1920
String line = br.readLine();
@@ -25,14 +26,14 @@ public static Coordinates[] readCoordinatesFromCSV(String fileName) {
2526
}
2627
String[] attributes = line.split(",");
2728
Coordinates coordinates = createCoordinates(attributes);
28-
coordinatesArray[i]=coordinates;
29+
coordinatesArrayList.add(coordinates);
2930
i++;
3031
line = br.readLine();
3132
}
3233
} catch (IOException ioe) {
3334
ioe.printStackTrace();
3435
}
35-
return coordinatesArray;
36+
return coordinatesArrayList.toArray(new Coordinates[0]);
3637
}
3738

3839
public static Coordinates createCoordinates(String[] line) {

0 commit comments

Comments
 (0)