From 17b579ba3c33fc13bb3589ca5c43a59014b656d0 Mon Sep 17 00:00:00 2001 From: Kai Nagel Date: Thu, 14 Mar 2024 10:26:41 +0100 Subject: [PATCH 1/2] rename Priority into Einstufung --- .../java/org/tub/vsp/bvwp/data/Headers.java | 4 +++- .../RailProjectInformationDataContainer.java | 8 +++---- ...StreetProjectInformationDataContainer.java | 8 +++---- .../RailProjectInformationMapper.java | 4 ++-- .../StreetProjectInformationMapper.java | 5 ++--- .../type/{Priority.java => Einstufung.java} | 10 ++++----- .../tub/vsp/bvwp/users/kmt/FiguresKMT.java | 22 +++++++++---------- .../users/kmt/RunLocalCsvScrapingKMT.java | 6 ++--- .../org/tub/vsp/bvwp/users/kn/FiguresKN.java | 9 ++++---- .../bvwp/users/kn/RunLocalCsvScrapingKN.java | 6 ++--- .../RailProjectInformationMapperTest.java | 6 ++--- .../StreetProjectInformationMapperTest.java | 4 ++-- 12 files changed, 46 insertions(+), 46 deletions(-) rename src/main/java/org/tub/vsp/bvwp/data/type/{Priority.java => Einstufung.java} (75%) diff --git a/src/main/java/org/tub/vsp/bvwp/data/Headers.java b/src/main/java/org/tub/vsp/bvwp/data/Headers.java index adb9c2f..a791b06 100644 --- a/src/main/java/org/tub/vsp/bvwp/data/Headers.java +++ b/src/main/java/org/tub/vsp/bvwp/data/Headers.java @@ -1,5 +1,7 @@ package org.tub.vsp.bvwp.data; +import org.tub.vsp.bvwp.data.type.Einstufung; + public final class Headers{ /** * Additional lane-km of the project. Estimated from length of the construction project and project type (e.g. "Neubau" vs. "Erweiterung"). @@ -67,7 +69,7 @@ public final class Headers{ /** * So etwas wie "VB-E", "VB", ... * - * @see org.tub.vsp.bvwp.data.type.Priority + * @see Einstufung */ public static final String EINSTUFUNG = "Einstufung"; /** diff --git a/src/main/java/org/tub/vsp/bvwp/data/container/base/rail/RailProjectInformationDataContainer.java b/src/main/java/org/tub/vsp/bvwp/data/container/base/rail/RailProjectInformationDataContainer.java index 16c2438..bd1d52d 100644 --- a/src/main/java/org/tub/vsp/bvwp/data/container/base/rail/RailProjectInformationDataContainer.java +++ b/src/main/java/org/tub/vsp/bvwp/data/container/base/rail/RailProjectInformationDataContainer.java @@ -1,13 +1,13 @@ package org.tub.vsp.bvwp.data.container.base.rail; -import org.tub.vsp.bvwp.data.type.Priority; +import org.tub.vsp.bvwp.data.type.Einstufung; import java.util.Objects; public class RailProjectInformationDataContainer { private String projectNumber; private String title; - private Priority priority; + private Einstufung priority; private String bautyp; private Double length; @@ -29,11 +29,11 @@ public RailProjectInformationDataContainer setTitle(String title) { return this; } - public Priority getPriority() { + public Einstufung getPriority() { return priority; } - public RailProjectInformationDataContainer setPriority(Priority priority) { + public RailProjectInformationDataContainer setPriority( Einstufung priority ) { this.priority = priority; return this; } diff --git a/src/main/java/org/tub/vsp/bvwp/data/container/base/street/StreetProjectInformationDataContainer.java b/src/main/java/org/tub/vsp/bvwp/data/container/base/street/StreetProjectInformationDataContainer.java index 751816e..53afc81 100644 --- a/src/main/java/org/tub/vsp/bvwp/data/container/base/street/StreetProjectInformationDataContainer.java +++ b/src/main/java/org/tub/vsp/bvwp/data/container/base/street/StreetProjectInformationDataContainer.java @@ -1,14 +1,14 @@ package org.tub.vsp.bvwp.data.container.base.street; import org.tub.vsp.bvwp.data.type.Bautyp; -import org.tub.vsp.bvwp.data.type.Priority; +import org.tub.vsp.bvwp.data.type.Einstufung; import java.util.Objects; public class StreetProjectInformationDataContainer { private String projectNumber; private String street; - private Priority priority; + private Einstufung priority; private Bautyp bautyp; private Double length; private Double verkehrsbelastung2030; @@ -31,11 +31,11 @@ public StreetProjectInformationDataContainer setStreet(String street) { return this; } - public Priority getPriority() { + public Einstufung getPriority() { return priority; } - public StreetProjectInformationDataContainer setPriority(Priority priority) { + public StreetProjectInformationDataContainer setPriority( Einstufung priority ) { this.priority = priority; return this; } diff --git a/src/main/java/org/tub/vsp/bvwp/data/mapper/projectInformation/RailProjectInformationMapper.java b/src/main/java/org/tub/vsp/bvwp/data/mapper/projectInformation/RailProjectInformationMapper.java index 1b808bb..6df1ad9 100644 --- a/src/main/java/org/tub/vsp/bvwp/data/mapper/projectInformation/RailProjectInformationMapper.java +++ b/src/main/java/org/tub/vsp/bvwp/data/mapper/projectInformation/RailProjectInformationMapper.java @@ -3,7 +3,7 @@ import org.jsoup.nodes.Document; import org.tub.vsp.bvwp.JSoupUtils; import org.tub.vsp.bvwp.data.container.base.rail.RailProjectInformationDataContainer; -import org.tub.vsp.bvwp.data.type.Priority; +import org.tub.vsp.bvwp.data.type.Einstufung; import java.text.ParseException; @@ -26,7 +26,7 @@ public static RailProjectInformationDataContainer mapDocument(Document document) return projectInformation.setProjectNumber(projectNumber) .setTitle(titel) .setLength(JSoupUtils.parseDouble(length)) - .setPriority(Priority.getFromString(priority)); + .setPriority( Einstufung.getFromString(priority ) ); } catch (ParseException e) { throw new RuntimeException(e); } diff --git a/src/main/java/org/tub/vsp/bvwp/data/mapper/projectInformation/StreetProjectInformationMapper.java b/src/main/java/org/tub/vsp/bvwp/data/mapper/projectInformation/StreetProjectInformationMapper.java index decff28..1b90b49 100644 --- a/src/main/java/org/tub/vsp/bvwp/data/mapper/projectInformation/StreetProjectInformationMapper.java +++ b/src/main/java/org/tub/vsp/bvwp/data/mapper/projectInformation/StreetProjectInformationMapper.java @@ -4,10 +4,9 @@ import org.apache.logging.log4j.Logger; import org.jsoup.nodes.Document; import org.tub.vsp.bvwp.JSoupUtils; -import org.tub.vsp.bvwp.computation.ConsoleColors; import org.tub.vsp.bvwp.data.container.base.street.StreetProjectInformationDataContainer; import org.tub.vsp.bvwp.data.type.Bautyp; -import org.tub.vsp.bvwp.data.type.Priority; +import org.tub.vsp.bvwp.data.type.Einstufung; import java.text.ParseException; @@ -50,7 +49,7 @@ public static StreetProjectInformationDataContainer mapDocument(Document documen .setStreet(street) .setLength(JSoupUtils.parseDouble(length)) .setBautyp(Bautyp.getFromString(bautyp)) - .setPriority(Priority.getFromString(priority)) + .setPriority( Einstufung.getFromString(priority ) ) .setVerkehrsbelastungPlanfall( JSoupUtils.parseDouble( verkehrsbelastungPlanfall ) ); } catch (ParseException e) { throw new RuntimeException(e); diff --git a/src/main/java/org/tub/vsp/bvwp/data/type/Priority.java b/src/main/java/org/tub/vsp/bvwp/data/type/Einstufung.java similarity index 75% rename from src/main/java/org/tub/vsp/bvwp/data/type/Priority.java rename to src/main/java/org/tub/vsp/bvwp/data/type/Einstufung.java index 8868453..e7c93c8 100644 --- a/src/main/java/org/tub/vsp/bvwp/data/type/Priority.java +++ b/src/main/java/org/tub/vsp/bvwp/data/type/Einstufung.java @@ -3,7 +3,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -public enum Priority{ +public enum Einstufung{ VBE("Vordringlicher Bedarf - Engpassbeseitigung (VB-E)"), VB("Vordringlicher Bedarf (VB)"), WBP("Weiterer Bedarf mit Planungsrecht (WB*)"), @@ -11,16 +11,16 @@ public enum Priority{ @Deprecated // yyyyyy lieber aufklären!! UNDEFINED("undefined"); - private static final Logger log = LogManager.getLogger( Priority.class ); + private static final Logger log = LogManager.getLogger( Einstufung.class ); public final String description; - Priority( String description ) { + Einstufung( String description ) { this.description = description; } - public static Priority getFromString( String description ) { - for ( Priority v : values()){ + public static Einstufung getFromString( String description ) { + for ( Einstufung v : values()){ if( v.description.equalsIgnoreCase( description ) ){ return v; } diff --git a/src/main/java/org/tub/vsp/bvwp/users/kmt/FiguresKMT.java b/src/main/java/org/tub/vsp/bvwp/users/kmt/FiguresKMT.java index 0e309ee..e1d56cf 100644 --- a/src/main/java/org/tub/vsp/bvwp/users/kmt/FiguresKMT.java +++ b/src/main/java/org/tub/vsp/bvwp/users/kmt/FiguresKMT.java @@ -2,7 +2,7 @@ import org.tub.vsp.bvwp.BvwpUtils; import org.tub.vsp.bvwp.data.Headers; -import org.tub.vsp.bvwp.data.type.Priority; +import org.tub.vsp.bvwp.data.type.Einstufung; import tech.tablesaw.api.Table; import tech.tablesaw.plotly.components.Axis; import tech.tablesaw.plotly.components.Axis.Type; @@ -20,8 +20,8 @@ class FiguresKMT { //Do not instanciate FiguresKMT(){} - private static Trace getPriorityTrace( Table table, Priority priority, String xName, String yName, - String color){ + private static Trace getPriorityTrace( Table table, Einstufung priority, String xName, String yName, + String color){ Table tableVbe = BvwpUtils.extractPriorityTable(table, priority.name()); return ScatterTrace.builder( tableVbe.numberColumn( xName ), tableVbe.numberColumn( yName ) ) .text( tableVbe.stringColumn( Headers.PROJECT_NAME ).asObjectArray() ) @@ -61,10 +61,10 @@ static Figure createFigureCostByPriority(int plotWidth, Table table, String xNam .name( String.format( legendFormat, yName ) ) .build(); - final Trace traceWb = getPriorityTrace(table, Priority.WB, xName, y2Name, "cyan"); - final Trace traceWbp = getPriorityTrace(table, Priority.WBP, xName, y2Name, "yellow"); - final Trace traceVb = getPriorityTrace(table, Priority.VB, xName, y2Name, "orange"); - final Trace traceVbe = getPriorityTrace( table, Priority.VBE , xName, y2Name, "red" ); + final Trace traceWb = getPriorityTrace(table, Einstufung.WB, xName, y2Name, "cyan" ); + final Trace traceWbp = getPriorityTrace(table, Einstufung.WBP, xName, y2Name, "yellow" ); + final Trace traceVb = getPriorityTrace(table, Einstufung.VB, xName, y2Name, "orange" ); + final Trace traceVbe = getPriorityTrace( table, Einstufung.VBE , xName, y2Name, "red" ); Trace trace3 = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( y3Name ) ) .text( table.stringColumn( Headers.PROJECT_NAME ).asObjectArray() ) @@ -101,10 +101,10 @@ static Figure createFigureNkvByPriority( Axis xAxis, int plotWidth, Table table, .name( String.format( legendFormat, String.format( "%30s" , yName ) ) ) .build(); - final Trace traceWb = getPriorityTrace(table, Priority.WB, xName, y2Name, "cyan"); - final Trace traceWbp = getPriorityTrace(table, Priority.WBP, xName, y2Name, "yellow"); - final Trace traceVb = getPriorityTrace(table, Priority.VB, xName, y2Name, "orange"); - final Trace traceVbe = getPriorityTrace( table, Priority.VBE , xName, y2Name, "red" ); + final Trace traceWb = getPriorityTrace(table, Einstufung.WB, xName, y2Name, "cyan" ); + final Trace traceWbp = getPriorityTrace(table, Einstufung.WBP, xName, y2Name, "yellow" ); + final Trace traceVb = getPriorityTrace(table, Einstufung.VB, xName, y2Name, "orange" ); + final Trace traceVbe = getPriorityTrace( table, Einstufung.VBE , xName, y2Name, "red" ); Trace trace3 = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( y3Name ) ) diff --git a/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java b/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java index 5e80dfe..626b853 100644 --- a/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java +++ b/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java @@ -20,7 +20,7 @@ import org.tub.vsp.bvwp.BvwpUtils; import org.tub.vsp.bvwp.data.Headers; import org.tub.vsp.bvwp.data.container.analysis.StreetAnalysisDataContainer; -import org.tub.vsp.bvwp.data.type.Priority; +import org.tub.vsp.bvwp.data.type.Einstufung; import org.tub.vsp.bvwp.io.StreetCsvWriter; import org.tub.vsp.bvwp.plot.MultiPlotUtils; import org.tub.vsp.bvwp.scraping.StreetScraper; @@ -133,8 +133,8 @@ public static void main(String[] args) throws IOException { // === Some calculations Comparator comparator = (o1, o2) -> { - Priority p1 = Priority.valueOf(o1.getString(Headers.EINSTUFUNG ) ); - Priority p2 = Priority.valueOf(o2.getString(Headers.EINSTUFUNG ) ); + Einstufung p1 = Einstufung.valueOf(o1.getString(Headers.EINSTUFUNG ) ); + Einstufung p2 = Einstufung.valueOf(o2.getString(Headers.EINSTUFUNG ) ); return p1.compareTo(p2); }; table = table.sortOn(comparator); diff --git a/src/main/java/org/tub/vsp/bvwp/users/kn/FiguresKN.java b/src/main/java/org/tub/vsp/bvwp/users/kn/FiguresKN.java index ea86e2f..fef7c02 100644 --- a/src/main/java/org/tub/vsp/bvwp/users/kn/FiguresKN.java +++ b/src/main/java/org/tub/vsp/bvwp/users/kn/FiguresKN.java @@ -4,7 +4,7 @@ import org.apache.logging.log4j.Logger; import org.tub.vsp.bvwp.computation.ComputationKN; import org.tub.vsp.bvwp.data.Headers; -import org.tub.vsp.bvwp.data.type.Priority; +import org.tub.vsp.bvwp.data.type.Einstufung; import tech.tablesaw.api.DoubleColumn; import tech.tablesaw.api.NumericColumn; import tech.tablesaw.api.Table; @@ -117,7 +117,7 @@ class FiguresKN{ DoubleColumn column = DoubleColumn.create( Headers.EINSTUFUNG_AS_NUMBER ); final double factor = 5.; for( String prio : table.stringColumn( Headers.EINSTUFUNG ) ){ - switch( Priority.valueOf( prio ) ){ + switch( Einstufung.valueOf( prio ) ){ case VBE -> { column.append( 4. * factor ); } @@ -160,7 +160,6 @@ class FiguresKN{ new CsvWriter().write( table, CsvWriteOptions.builder( new File( "output.tsv" ) ).separator( '\t' ).usePrintFormatters( true ).build() ); - System.exit(-1); } Figure createFigureCostVsLanekm(){ // String xName = Headers.ADDTL_LANE_KM; @@ -442,8 +441,8 @@ public Figure createFigureFzkmNewVsLanekm(){ final Trace traceVb = getTraceOrange( table, xName, y2Name ); final Trace traceVbe = getTraceRed( table, xName, y2Name ); - log.warn( table.where( table.stringColumn( Headers.PROJECT_NAME ).startsWith( "A008" ) ) ); - log.warn("here"); +// log.warn( table.where( table.stringColumn( Headers.PROJECT_NAME ).startsWith( "A008" ) ) ); +// log.warn("here"); return new Figure( layout , trace diff --git a/src/main/java/org/tub/vsp/bvwp/users/kn/RunLocalCsvScrapingKN.java b/src/main/java/org/tub/vsp/bvwp/users/kn/RunLocalCsvScrapingKN.java index 2caa770..d4e1d77 100644 --- a/src/main/java/org/tub/vsp/bvwp/users/kn/RunLocalCsvScrapingKN.java +++ b/src/main/java/org/tub/vsp/bvwp/users/kn/RunLocalCsvScrapingKN.java @@ -5,7 +5,7 @@ import org.tub.vsp.bvwp.BvwpUtils; import org.tub.vsp.bvwp.data.Headers; import org.tub.vsp.bvwp.data.container.analysis.StreetAnalysisDataContainer; -import org.tub.vsp.bvwp.data.type.Priority; +import org.tub.vsp.bvwp.data.type.Einstufung; import org.tub.vsp.bvwp.io.StreetCsvWriter; import org.tub.vsp.bvwp.plot.MultiPlotUtils; import org.tub.vsp.bvwp.scraping.StreetScraper; @@ -97,8 +97,8 @@ public static void main(String[] args) throws IOException{ // === Comparator comparator = ( o1, o2 ) -> { - Priority p1 = Priority.valueOf( o1.getString( Headers.EINSTUFUNG ) ); - Priority p2 = Priority.valueOf( o2.getString( Headers.EINSTUFUNG ) ); + Einstufung p1 = Einstufung.valueOf( o1.getString( Headers.EINSTUFUNG ) ); + Einstufung p2 = Einstufung.valueOf( o2.getString( Headers.EINSTUFUNG ) ); return p1.compareTo( p2 ); }; table = table.sortOn( comparator ); diff --git a/src/test/java/org/tub/vsp/bvwp/data/mapper/projectInformation/RailProjectInformationMapperTest.java b/src/test/java/org/tub/vsp/bvwp/data/mapper/projectInformation/RailProjectInformationMapperTest.java index 8440921..1837e60 100644 --- a/src/test/java/org/tub/vsp/bvwp/data/mapper/projectInformation/RailProjectInformationMapperTest.java +++ b/src/test/java/org/tub/vsp/bvwp/data/mapper/projectInformation/RailProjectInformationMapperTest.java @@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test; import org.tub.vsp.bvwp.data.LocalFileAccessor; import org.tub.vsp.bvwp.data.container.base.rail.RailProjectInformationDataContainer; -import org.tub.vsp.bvwp.data.type.Priority; +import org.tub.vsp.bvwp.data.type.Einstufung; import java.io.IOException; @@ -19,7 +19,7 @@ void testMapping() throws IOException { Assertions.assertEquals("\"optimiertes Alpha\" (Bezeichnung noch offen)", railProjectInformationDataContainer.getTitle()); Assertions.assertEquals(188.10, railProjectInformationDataContainer.getLength()); - Assertions.assertEquals(Priority.UNDEFINED, railProjectInformationDataContainer.getPriority()); + Assertions.assertEquals( Einstufung.UNDEFINED, railProjectInformationDataContainer.getPriority() ); } -} \ No newline at end of file +} diff --git a/src/test/java/org/tub/vsp/bvwp/data/mapper/projectInformation/StreetProjectInformationMapperTest.java b/src/test/java/org/tub/vsp/bvwp/data/mapper/projectInformation/StreetProjectInformationMapperTest.java index fc67a3c..868c34d 100644 --- a/src/test/java/org/tub/vsp/bvwp/data/mapper/projectInformation/StreetProjectInformationMapperTest.java +++ b/src/test/java/org/tub/vsp/bvwp/data/mapper/projectInformation/StreetProjectInformationMapperTest.java @@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test; import org.tub.vsp.bvwp.data.LocalFileAccessor; import org.tub.vsp.bvwp.data.container.base.street.StreetProjectInformationDataContainer; -import org.tub.vsp.bvwp.data.type.Priority; +import org.tub.vsp.bvwp.data.type.Einstufung; import java.io.IOException; @@ -18,6 +18,6 @@ void testMapping() throws IOException { Assertions.assertEquals("A20-G10-NI-SH", mappingResult.getProjectNumber()); Assertions.assertEquals("A 20", mappingResult.getStreet()); - Assertions.assertEquals(Priority.VB, mappingResult.getPriority()); + Assertions.assertEquals( Einstufung.VB, mappingResult.getPriority() ); } } From 0498987b68d401bb6130c4b5753e7608abd3a3cd Mon Sep 17 00:00:00 2001 From: Kai Nagel Date: Thu, 14 Mar 2024 11:13:05 +0100 Subject: [PATCH 2/2] put elasticity values into column headers --- .../java/org/tub/vsp/bvwp/RunCsvWriting.java | 2 +- .../org/tub/vsp/bvwp/RunLocalCsvScraping.java | 2 +- .../java/org/tub/vsp/bvwp/data/Headers.java | 26 +-- .../analysis/StreetAnalysisDataContainer.java | 30 ++-- .../tub/vsp/bvwp/users/kmt/FiguresKMT.java | 2 +- .../users/kmt/RunLocalCsvScrapingKMT.java | 10 +- .../org/tub/vsp/bvwp/users/kn/FiguresKN.java | 151 +++++++++++------- .../bvwp/users/kn/RunLocalCsvScrapingKN.java | 12 +- .../tub/vsp/bvwp/io/StreetCsvWriterTest.java | 2 +- 9 files changed, 136 insertions(+), 101 deletions(-) diff --git a/src/main/java/org/tub/vsp/bvwp/RunCsvWriting.java b/src/main/java/org/tub/vsp/bvwp/RunCsvWriting.java index ceb9b6c..58ad7f4 100644 --- a/src/main/java/org/tub/vsp/bvwp/RunCsvWriting.java +++ b/src/main/java/org/tub/vsp/bvwp/RunCsvWriting.java @@ -11,7 +11,7 @@ public static void main(String[] args) { List allStreetBaseData = new StreetScraper().extractAllLocalBaseData("./data/street/all", "A", ".*") .stream() - .map( streetBaseDataContainer -> new StreetAnalysisDataContainer( streetBaseDataContainer, 0.6, 1. ) ) + .map( streetBaseDataContainer -> new StreetAnalysisDataContainer( streetBaseDataContainer, 1. ) ) .toList(); StreetCsvWriter csvWriter = new StreetCsvWriter("output/street_data.csv"); diff --git a/src/main/java/org/tub/vsp/bvwp/RunLocalCsvScraping.java b/src/main/java/org/tub/vsp/bvwp/RunLocalCsvScraping.java index 386cd9c..e59b1cf 100644 --- a/src/main/java/org/tub/vsp/bvwp/RunLocalCsvScraping.java +++ b/src/main/java/org/tub/vsp/bvwp/RunLocalCsvScraping.java @@ -26,7 +26,7 @@ public static void main(String[] args) { logger.info("Starting scraping"); List allStreetBaseData = scraper.extractAllLocalBaseData("./data/street", "A", ".*" ) .stream() - .map( streetBaseDataContainer -> new StreetAnalysisDataContainer( streetBaseDataContainer, 0.6, 1. ) ) + .map( streetBaseDataContainer -> new StreetAnalysisDataContainer( streetBaseDataContainer, 1. ) ) .toList(); logger.info("Writing csv"); diff --git a/src/main/java/org/tub/vsp/bvwp/data/Headers.java b/src/main/java/org/tub/vsp/bvwp/data/Headers.java index a791b06..7be78f9 100644 --- a/src/main/java/org/tub/vsp/bvwp/data/Headers.java +++ b/src/main/java/org/tub/vsp/bvwp/data/Headers.java @@ -8,9 +8,9 @@ public final class Headers{ */ public static final String ADDTL_LANE_KM = "addtl_lane_km"; /** - * = {@link #ADDTL_PKWKM_NEU} - {@link #ADDTL_PKWKM_ORIG} + * = {@link #ADDTL_PKWKM_EL03} - {@link #ADDTL_PKWKM_ORIG} */ - public static final String ADDTL_PKWKM_DIFF = "addtl_pkwkm_diff"; + public static final String ADDTL_PKWKM_EL03_DIFF = "addtl_pkwkm_el03_diff"; /** * Der "induzierte" (Mehr-)Verkehr laut PRINS. */ @@ -19,7 +19,7 @@ public final class Headers{ * Mehrverkehr auf Pkw, den das Projekt erzeugt, laut unserer eigenen Abschätzung. Wird immer mal mit anderen Elastizitäten gerechnet, so * dass sich die Werte immer mal ändern. */ - public static final String ADDTL_PKWKM_NEU = "addtl_pkwkm_new"; + public static final String ADDTL_PKWKM_EL03 = "addtl_pkwkm_el03"; /** * Mehrverkehr auf Pkw, den das Projekt erzeugt, laut PRINS. */ @@ -83,7 +83,7 @@ public final class Headers{ /** * min( 5 , {@link #NKV_ORIG} ) */ - public static final String NKV_ORIG_CAPPED5 = "NKV_orig_capped"; + public static final String NKV_ORIG_CAPPED5 = "NKV_orig_capped5"; /** * NKV bei erhöhtem CO2-Preis (welchem?). */ @@ -91,29 +91,29 @@ public final class Headers{ public static final String NKV_CO2_2000_EN = "BCR_co2_2000"; public static final String NKV_CO2_680_EN = "BCR_co2_680"; /** - * {@link #NKV_INDUZ_CO2215_CONSTRUCTION} - {@link #NKV_ORIG} + * {@link #NKV_EL03_CO2_215_CONSTRUCTION} - {@link #NKV_ORIG} */ - public static final String NKV_DIFF = "nkvDiff"; + public static final String NKV_EL03_DIFF = "NKV_el03_Diff"; /** * Neues NKV bei erhöhter Abschätzung für Mehrverkehr. */ - public static final String NKV_INDUZ = "NKV_induz"; + public static final String NKV_EL03 = "NKV_el03"; /** * Neues NKV mit höherem Mehrverkehr, CO2-Preis 215, sowie höheren Investitionskosten. */ - public static final String NKV_INDUZ_CO2215_CONSTRUCTION = "NKV_induzCo2215Invkosten"; + public static final String NKV_EL03_CO2_215_CONSTRUCTION = "NKV_el03Co2_215Invkosten"; /** - * min( 5, {@link #NKV_INDUZ_CO2215_CONSTRUCTION}) + * min( 5, {@link #NKV_EL03_CO2_215_CONSTRUCTION}) */ - public static final String NKV_INDUZ_CO2215_CONSTRUCTION_CAPPED5 = "NKV_induzCo2215Invkosten_capped5"; + public static final String NKV_EL03_CO2_215_CONSTRUCTION_CAPPED5 = "NKV_el03Co2_215Invkosten_capped5"; /** * Neues NKV mit höherem Mehrverkehr, höherem CO2-Preis, höheren Investitionskosten. */ - public static final String NKV_INDUZ_CO2_CONSTRUCTION = "NKV_induzCo2Invkosten"; + public static final String NKV_EL03_CO2_CONSTRUCTION = "NKV_el03Co2Invkosten"; /** - * min( 5, {@link #NKV_INDUZ_CO2_CONSTRUCTION} ) + * min( 5, {@link #NKV_EL03_CO2_CONSTRUCTION} ) */ - public static final String NKV_INDUZ_CO2_CONSTRUCTION_CAPPED5 = "NKV_induzCo2Invkosten_capped5"; + public static final String NKV_EL03_CO2_CONSTRUCTION_CAPPED5 = "NKV_el03Co2Invkosten_capped5"; public static final String NKV_INDUZ_CO2_EN = "BCR_induzCo2"; public static final String NKV_INDUZ_EN = "BCR_induz"; public static final String NKV_NO_CHANGE_EN = "BCR"; diff --git a/src/main/java/org/tub/vsp/bvwp/data/container/analysis/StreetAnalysisDataContainer.java b/src/main/java/org/tub/vsp/bvwp/data/container/analysis/StreetAnalysisDataContainer.java index c882b86..3fd7b64 100644 --- a/src/main/java/org/tub/vsp/bvwp/data/container/analysis/StreetAnalysisDataContainer.java +++ b/src/main/java/org/tub/vsp/bvwp/data/container/analysis/StreetAnalysisDataContainer.java @@ -19,14 +19,12 @@ public class StreetAnalysisDataContainer { Logger logger = LogManager.getLogger(StreetAnalysisDataContainer.class); private final StreetBaseDataContainer streetBaseData; - private final double elasticity; private final double constructionCostFactor; private final SequencedMap entries = new LinkedHashMap<>(); private final List remarks = new ArrayList<>(); - public StreetAnalysisDataContainer( StreetBaseDataContainer streetBaseDataContainer, double elasticity, double constructionCostFactor ) { + public StreetAnalysisDataContainer( StreetBaseDataContainer streetBaseDataContainer, double constructionCostFactor ) { this.streetBaseData = streetBaseDataContainer; - this.elasticity = elasticity; this.constructionCostFactor = constructionCostFactor; logger.info(this.streetBaseData.getUrl() ); this.addComputations(); @@ -34,10 +32,10 @@ public StreetAnalysisDataContainer( StreetBaseDataContainer streetBaseDataContai private void addComputations() { // double fzkm_induz = streetBaseDataContainer.getPhysicalEffect().getVehicleKilometers().induced(); - // double addtlFzkmFromElasticity = 4. * fzkm_induz; -// if (addtlFzkmFromElasticity == 0.) { + // double addtlFzkmFromElasticity03 = 4. * fzkm_induz; +// if (addtlFzkmFromElasticity03 == 0.) { // double fzkm = streetBaseDataContainer.getPhysicalEffect().getVehicleKilometers().overall(); -// addtlFzkmFromElasticity = 4. * fzkm; +// addtlFzkmFromElasticity03 = 4. * fzkm; // } // yyyyyy die obige Rechnung muss schlussendlich genauer sein ... zusätzliche Spurkm / 60000 * 0.6 * // Jahresfahrleistung_AB @@ -94,11 +92,11 @@ private void addComputations() { entries.put( Headers.ADDTL_LANE_KM, additionalLaneKm ); - double addtlFzkmFromElasticity = additionalLaneKm / ComputationKN.LANE_KM_AB * elasticity * ComputationKN.FZKM_AB; - final double addtlFzkmBeyondPRINS = addtlFzkmFromElasticity - streetBaseData.getPhysicalEffect().getVehicleKilometers().overall(); - // (this is formulated such that addtlFzkmBeyondPRINS=0 means the original additional Fzkm) + double addtlFzkmFromElasticity03 = additionalLaneKm / ComputationKN.LANE_KM_AB * 0.3 * ComputationKN.FZKM_AB; + final double addtlFzkmBeyondPrinsEl03 = addtlFzkmFromElasticity03 - streetBaseData.getPhysicalEffect().getVehicleKilometers().overall(); + // (this is formulated such that addtlFzkmBeyondPrinsEl03=0 means the original additional Fzkm) -// logger.info("addtlFzkmBeyondPRINS=" + addtlFzkmBeyondPRINS); +// logger.info("addtlFzkmBeyondPrinsEl03=" + addtlFzkmBeyondPrinsEl03); // entries.put("cost/km", streetBaseDataContainer.getCostBenefitAnalysis().getCost().overallCosts() / // streetBaseDataContainer.getProjectInformation().getLength() ); // entries.put("rz", streetBaseDataContainer.getPhysicalEffect().getTravelTimes().overall()); @@ -109,14 +107,14 @@ private void addComputations() { entries.put(Headers.NKV_CO2, NkvCalculator.calculateNkv( new Modifications(co2Price680, 0., 1 ), streetBaseData ) ); entries.put(Headers.NKV_CO2_680_EN, NkvCalculator.calculateNkv( new Modifications(co2Price680, 0., 1 ), streetBaseData ) ); entries.put(Headers.NKV_CO2_2000_EN, NkvCalculator.calculateNkv( new Modifications( 2000 * INFLATION_Factor2022to2012, 0, 1 ), streetBaseData ) ); - entries.put(Headers.NKV_INDUZ, NkvCalculator.calculateNkv( new Modifications( co2PriceBVWP, addtlFzkmBeyondPRINS, 1 ), streetBaseData ) ); - entries.put(Headers.NKV_INDUZ_CO2215_CONSTRUCTION, - NkvCalculator.calculateNkv( new Modifications( 215, addtlFzkmBeyondPRINS, constructionCostFactor ), streetBaseData ) ); - entries.put(Headers.NKV_INDUZ_CO2_CONSTRUCTION, NkvCalculator.calculateNkv( new Modifications( co2Price680, addtlFzkmBeyondPRINS, constructionCostFactor ), streetBaseData ) ); - entries.put(Headers.ADDTL_PKWKM_NEU, addtlFzkmFromElasticity ); + entries.put(Headers.NKV_EL03, NkvCalculator.calculateNkv( new Modifications( co2PriceBVWP, addtlFzkmBeyondPrinsEl03, 1 ), streetBaseData ) ); + entries.put(Headers.NKV_EL03_CO2_215_CONSTRUCTION, + NkvCalculator.calculateNkv( new Modifications( 215, addtlFzkmBeyondPrinsEl03, constructionCostFactor ), streetBaseData ) ); + entries.put(Headers.NKV_EL03_CO2_CONSTRUCTION, NkvCalculator.calculateNkv( new Modifications( co2Price680, addtlFzkmBeyondPrinsEl03, constructionCostFactor ), streetBaseData ) ); + entries.put(Headers.ADDTL_PKWKM_EL03, addtlFzkmFromElasticity03 ); entries.put(Headers.CO2_COST_ORIG, Math.max( 1., NkvCalculator.calculateCost_CO2( NO_CHANGE, streetBaseData ) ) ); entries.put(Headers.CO2_COST_NEU, - Math.max( 1., NkvCalculator.calculateCost_CO2( new Modifications( co2PriceBVWP, addtlFzkmBeyondPRINS, 1 ), streetBaseData ) ) ); + Math.max( 1., NkvCalculator.calculateCost_CO2( new Modifications( co2PriceBVWP, addtlFzkmBeyondPrinsEl03, 1 ), streetBaseData ) ) ); // ("max(1,...)" so that they become visible on logplot. find other solution! if ( streetBaseData.getProjectInformation().getProjectNumber().contains("A1-G50-NI" )) { diff --git a/src/main/java/org/tub/vsp/bvwp/users/kmt/FiguresKMT.java b/src/main/java/org/tub/vsp/bvwp/users/kmt/FiguresKMT.java index e1d56cf..ba53953 100644 --- a/src/main/java/org/tub/vsp/bvwp/users/kmt/FiguresKMT.java +++ b/src/main/java/org/tub/vsp/bvwp/users/kmt/FiguresKMT.java @@ -84,7 +84,7 @@ static Figure createFigureNkvByPriority( Axis xAxis, int plotWidth, Table table, Figure figure2; String yName = Headers.NKV_ORIG; String y3Name = Headers.NKV_CO2_680_EN; - String y2Name = Headers.NKV_INDUZ_CO2_CONSTRUCTION; + String y2Name = Headers.NKV_EL03_CO2_CONSTRUCTION; Axis yAxis = Axis.builder() // .type( Axis.Type.LOG ) // wirft NKV < 0 raus! diff --git a/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java b/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java index 626b853..0bd292a 100644 --- a/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java +++ b/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java @@ -63,7 +63,7 @@ public static void main(String[] args) throws IOException { List allStreetBaseData = scraper .extractAllLocalBaseData("./data/street/all2", "A", ".*") .stream() - .map( streetBaseDataContainer -> new StreetAnalysisDataContainer( streetBaseDataContainer, 0.6, 1. ) ) + .map( streetBaseDataContainer -> new StreetAnalysisDataContainer( streetBaseDataContainer, 1. ) ) .toList(); logger.info("Writing csv"); @@ -73,8 +73,8 @@ public static void main(String[] args) throws IOException { // table = table.where( table.numberColumn( Headers.NKV_INDUZ_CO2 ).isLessThan( 2.) ); table.addColumns(table.numberColumn(Headers.NKV_ORIG ) - .subtract(table.numberColumn(Headers.NKV_INDUZ_CO2_CONSTRUCTION ) ).setName( - Headers.NKV_DIFF )); + .subtract(table.numberColumn(Headers.NKV_EL03_CO2_CONSTRUCTION ) ).setName( + Headers.NKV_EL03_DIFF ) ); // final Table newTable = table.selectColumns( "nkvDiff", Headers.COST_OVERALL ); // LinearModel winsModel = OLS.fit( Formula.lhs("nkvDiff" ), newTable.smile().toDataFrame() ); @@ -147,7 +147,7 @@ public static void main(String[] args) throws IOException { Table tableCo2_680_Kl1 = table.where(table.numberColumn(Headers.NKV_CO2_680_EN).isLessThan(1.)); Table tableCo2_2000_Kl1 = table.where(table.numberColumn(Headers.NKV_CO2_2000_EN).isLessThan(1.)); Table tableIndCo2kl1 = table.where( - table.numberColumn(Headers.NKV_INDUZ_CO2_CONSTRUCTION ).isLessThan(1. ) ); + table.numberColumn(Headers.NKV_EL03_CO2_CONSTRUCTION ).isLessThan(1. ) ); { //-- von KN System.out.println(BvwpUtils.SEPARATOR); @@ -155,7 +155,7 @@ public static void main(String[] args) throws IOException { .by(Headers.EINSTUFUNG ) ); System.out.println(System.lineSeparator() + "Davon NKV < 1:"); System.out.println( - tableIndCo2kl1.summarize(Headers.NKV_INDUZ_CO2_CONSTRUCTION, count, mean, stdDev, min, max ) + tableIndCo2kl1.summarize(Headers.NKV_EL03_CO2_CONSTRUCTION, count, mean, stdDev, min, max ) .by(Headers.EINSTUFUNG ) ); System.out.println(BvwpUtils.SEPARATOR); diff --git a/src/main/java/org/tub/vsp/bvwp/users/kn/FiguresKN.java b/src/main/java/org/tub/vsp/bvwp/users/kn/FiguresKN.java index fef7c02..f923f56 100644 --- a/src/main/java/org/tub/vsp/bvwp/users/kn/FiguresKN.java +++ b/src/main/java/org/tub/vsp/bvwp/users/kn/FiguresKN.java @@ -67,15 +67,15 @@ class FiguresKN{ // ============================================ table.addColumns( - table.numberColumn( Headers.NKV_INDUZ_CO2_CONSTRUCTION ).subtract( table.numberColumn( Headers.NKV_ORIG ) ).setName( Headers.NKV_DIFF ) - ,table.numberColumn( Headers.ADDTL_PKWKM_NEU ).subtract( table.numberColumn( Headers.ADDTL_PKWKM_ORIG ) ).setName( Headers.ADDTL_PKWKM_DIFF ) + table.numberColumn( Headers.NKV_EL03_CO2_CONSTRUCTION ).subtract( table.numberColumn( Headers.NKV_ORIG ) ).setName( Headers.NKV_EL03_DIFF ) + ,table.numberColumn( Headers.ADDTL_PKWKM_EL03 ).subtract( table.numberColumn( Headers.ADDTL_PKWKM_ORIG ) ).setName( Headers.ADDTL_PKWKM_EL03_DIFF ) ); // ============================================ // ============================================ final double cap=5.; { - DoubleColumn newColumn = DoubleColumn.create( Headers.NKV_INDUZ_CO2_CONSTRUCTION_CAPPED5 ); - for( Double number : table.doubleColumn( Headers.NKV_INDUZ_CO2_CONSTRUCTION ) ){ + DoubleColumn newColumn = DoubleColumn.create( Headers.NKV_EL03_CO2_CONSTRUCTION_CAPPED5 ); + for( Double number : table.doubleColumn( Headers.NKV_EL03_CO2_CONSTRUCTION ) ){ number = Math.min( number,cap - Math.random()*0.1 + 0.05 ); newColumn.append( number ); } @@ -84,8 +84,8 @@ class FiguresKN{ // ============================================ // ============================================ { - DoubleColumn newColumn = DoubleColumn.create( Headers.NKV_INDUZ_CO2215_CONSTRUCTION_CAPPED5 ); - for( Double number : table.doubleColumn( Headers.NKV_INDUZ_CO2215_CONSTRUCTION ) ){ + DoubleColumn newColumn = DoubleColumn.create( Headers.NKV_EL03_CO2_215_CONSTRUCTION_CAPPED5 ); + for( Double number : table.doubleColumn( Headers.NKV_EL03_CO2_215_CONSTRUCTION ) ){ number = Math.min( number, cap - Math.random()*0.1 + 0.05 ); newColumn.append( number ); } @@ -143,12 +143,13 @@ class FiguresKN{ table = table.sortAscendingOn( xName ); - this.xAxis = xAxisBuilder.title( xName ).build(); + + this.xAxis = xAxisBuilder.title( xName ).type( Axis.Type.LOG ).build(); this.table = table; nkvCappedMax = table.doubleColumn( Headers.NKV_ORIG_CAPPED5 ).max() + 0.2 ; - nkvMin = table.doubleColumn( Headers.NKV_INDUZ_CO2215_CONSTRUCTION_CAPPED5 ).min(); + nkvMin = table.doubleColumn( Headers.NKV_EL03_CO2_215_CONSTRUCTION_CAPPED5 ).min(); NumberFormat nf = NumberFormat.getInstance( Locale.GERMAN ); @@ -161,21 +162,24 @@ class FiguresKN{ new CsvWriter().write( table, CsvWriteOptions.builder( new File( "output.tsv" ) ).separator( '\t' ).usePrintFormatters( true ).build() ); } + // ################################################################ + // ################################################################ Figure createFigureCostVsLanekm(){ -// String xName = Headers.ADDTL_LANE_KM; -// Axis xAxis = Axis.builder().title(xName).type( Axis.Type.LOG ).build(); - - Figure figure3; String yName = Headers.COST_OVERALL; // String y3Name = Headers.COST_OVERALL; String y2Name = Headers.COST_OVERALL; + String title = ""; + if ( Headers.ADDTL_LANE_KM.equals( xName ) ) { + title = "construction cost SIMTO lane-km, but quite varied:"; + } + Axis yAxis = Axis.builder() .type( Axis.Type.LOG ) // .range( 1.1*table.numberColumn( y2Name ).min(),4. ) .title( yName ) .build(); - Layout layout = Layout.builder( "construction cost SIMTO lane-km, but quite varied:" ) + Layout layout = Layout.builder( title ) .xAxis( xAxis ) .yAxis( yAxis ) .width( plotWidth ) @@ -197,26 +201,29 @@ Figure createFigureCostVsLanekm(){ // .mode( ScatterTrace.Mode.LINE ) // .build(); - figure3 = new Figure( layout + Figure figure3 = new Figure( layout // , trace, trace3 , traceWb, traceWbp, traceVb, traceVbe ); return figure3; } + // ======================================================================================== + // ======================================================================================== Figure createFigureNkvVsLanekm(){ -// String xName = Headers.ADDTL_LANE_KM; -// Axis xAxis = Axis.builder().title(xName).type( Axis.Type.LOG ).build(); - - Figure figure2; - String yName = Headers.NKV_DIFF; + String yName = Headers.NKV_EL03_DIFF; // String y3Name = Headers.NKV_CO2; - String y2Name = Headers.NKV_DIFF; + String y2Name = Headers.NKV_EL03_DIFF; Axis yAxis = Axis.builder() // .type( Axis.Type.LOG ) // wirft NKV < 0 raus! // .range( 1.1*table.numberColumn( y2Name ).min(),4. ) .title( yName ) .build(); - Layout layout = Layout.builder( "since (co2_cost SIMTO lane-km) and (cost SIMTO lane-km), the division of the two does not depend on lane-km:" ) + + String title = ""; + if ( Headers.ADDTL_LANE_KM.equals( xName ) ){ + title = "since (co2_cost SIMTO lane-km) and (cost SIMTO lane-km), the division of the two does not depend on lane-km:"; + } + Layout layout = Layout.builder( title ) .xAxis( xAxis ) .yAxis( yAxis ) .width( plotWidth ) @@ -244,25 +251,26 @@ Figure createFigureNkvVsLanekm(){ // .mode( ScatterTrace.Mode.LINE ) // .build(); - figure2 = new Figure( layout + Figure figure2 = new Figure( layout // , trace // , trace3 - , traceCyan,traceMagenta - , traceOrange, traceRed + , traceCyan, traceMagenta + , traceOrange, traceRed // , trace4 - ); + ); return figure2; } + // ======================================================================================== + // ======================================================================================== Figure createFigurePkwKm( ){ - Figure figure; String yName = Headers.ADDTL_PKWKM_INDUZ_ORIG; - String y2Name = Headers.ADDTL_PKWKM_NEU; + String y2Name = Headers.ADDTL_PKWKM_EL03; Axis yAxis = Axis.builder() .title( yName ) .type( Axis.Type.LOG ) // sonst "0" nicht darstellbar .build(); - Layout layout = Layout.builder( "plot" ).xAxis( xAxis ).yAxis( yAxis ) + Layout layout = Layout.builder( "" ).xAxis( xAxis ).yAxis( yAxis ) .width( plotWidth ) .build(); @@ -281,13 +289,12 @@ Figure createFigurePkwKm( ){ // .mode( ScatterTrace.Mode.LINE ) // .build(); - figure = new Figure( layout, trace, traceWb, traceWbp, traceVb, traceVbe ); + Figure figure = new Figure( layout, trace, traceWb, traceWbp, traceVb, traceVbe ); return figure; } + // ======================================================================================== + // ======================================================================================== public Figure createFigureElasticities(){ -// String xName = Headers.ADDTL_LANE_KM; -// Axis xAxis = Axis.builder().title(xName).type( Axis.Type.LOG ).build(); - String yName = "elasticity_old"; String y2Name = "elasticity_new"; @@ -295,7 +302,7 @@ public Figure createFigureElasticities(){ .divide( ComputationKN.FZKM_AB ) .multiply( ComputationKN.LANE_KM_AB ) .divide( table.numberColumn( Headers.ADDTL_LANE_KM ) ).setName("elasticity_old" ), - table.numberColumn( Headers.ADDTL_PKWKM_NEU ) + table.numberColumn( Headers.ADDTL_PKWKM_EL03 ) .divide( ComputationKN.FZKM_AB ) .multiply( ComputationKN.LANE_KM_AB ) .divide( table.numberColumn( Headers.ADDTL_LANE_KM ) ).setName("elasticity_new" ) @@ -309,7 +316,11 @@ public Figure createFigureElasticities(){ // .range( -0.3, 0.8 ) .build(); - Layout layout = Layout.builder( "elasticities are indep of lane-km:" ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); + String title = ""; + if ( Headers.ADDTL_LANE_KM.equals( xName ) ){ + title = "elasticities are indep of lane-km:"; + } + Layout layout = Layout.builder( title ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) .name( String.format( legendFormat, yName ) ) @@ -333,8 +344,10 @@ public Figure createFigureElasticities(){ // traceWb, traceWbp, traceVb, traceVbe trace1, trace2 ); } + // ======================================================================================== + // ======================================================================================== public Figure createFigureFzkm(){ - String y2Name = Headers.ADDTL_PKWKM_NEU; + String y2Name = Headers.ADDTL_PKWKM_EL03; String yName = Headers.ADDTL_PKWKM_ORIG; Axis yAxis = Axis.builder().title( yName ) @@ -342,7 +355,7 @@ public Figure createFigureFzkm(){ // .range( 0.,400. ) .build(); - Layout layout = Layout.builder( "plot" ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); + Layout layout = Layout.builder( "" ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) .name( String.format( legendFormat, yName ) ) @@ -367,16 +380,20 @@ public Figure createFigureFzkm(){ ); } - Figure createFigureCO2VsLanekm(){ -// String xName = Headers.ADDTL_LANE_KM; -// Axis xAxis = Axis.builder().title(xName).type( Axis.Type.LOG ).build(); - + // ======================================================================================== + // ======================================================================================== + Figure createFigureCO2(){ String yName = Headers.CO2_COST_ORIG; String y2Name = Headers.CO2_COST_NEU; Axis yAxis = Axis.builder().title( yName ).type( Axis.Type.LOG ).build(); - Layout layout = Layout.builder( "CO2 costs SIMTO addtl lane-km:" ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); + String title = ""; + if ( Headers.ADDTL_LANE_KM.equals( xName ) ) { + title = "CO2 costs SIMTO addtl lane-km:"; + } + + Layout layout = Layout.builder( title ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) .name( String.format( legendFormat, yName ) ) @@ -393,13 +410,15 @@ Figure createFigureCO2VsLanekm(){ , trace , traceWb, traceWbp, traceVb, traceVbe ); } + // ======================================================================================== + // ======================================================================================== public Figure createFigureDtv(){ String yName = Headers.VERKEHRSBELASTUNG_PLANFALL; String y2Name = Headers.VERKEHRSBELASTUNG_PLANFALL; Axis yAxis = Axis.builder().title( yName ).type( Axis.Type.LOG ).build(); - Layout layout = Layout.builder( "plot" ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); + Layout layout = Layout.builder( "" ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); // Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) // .name( String.format( legendFormat, yName ) ) @@ -420,16 +439,18 @@ public Figure createFigureDtv(){ , traceVbe ); } - public Figure createFigureFzkmNewVsLanekm(){ -// String xName = Headers.ADDTL_LANE_KM; -// Axis xAxis = Axis.builder().title(xName).type( Axis.Type.LOG ).build(); - + public Figure createFigureFzkmNew(){ String yName = Headers.ADDTL_PKWKM_ORIG; - String y2Name = Headers.ADDTL_PKWKM_NEU; + String y2Name = Headers.ADDTL_PKWKM_EL03; Axis yAxis = Axis.builder().title( y2Name ).type( Axis.Type.LOG ).build(); - Layout layout = Layout.builder( "addtl_veh-km are PROPTO addtl_lane-km:" ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); + String title = ""; + if ( Headers.ADDTL_LANE_KM.equals( xName ) ){ + title = "addtl_veh-km are PROPTO addtl_lane-km:"; + } + + Layout layout = Layout.builder( title ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) .name( String.format( legendFormat, yName ) ) @@ -452,15 +473,19 @@ public Figure createFigureFzkmNewVsLanekm(){ , traceVbe ); } - public Figure createFigureFzkmDiffVsLanekm(){ -// String xName = Headers.ADDTL_LANE_KM; -// Axis xAxis = Axis.builder().title(xName).type( Axis.Type.LOG ).build(); - - String y2Name = Headers.ADDTL_PKWKM_DIFF; + // ======================================================================================== + // ======================================================================================== + public Figure createFigureFzkmDiff(){ + String y2Name = Headers.ADDTL_PKWKM_EL03_DIFF; Axis yAxis = Axis.builder().title( y2Name ).type( Axis.Type.LOG ).build(); - Layout layout = Layout.builder( "addtl_veh-km_diff are SIM addtl_lane-km:" ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); + String title = ""; + if ( Headers.ADDTL_LANE_KM.equals( xName ) ){ + title = "addtl_veh-km_diff are SIM addtl_lane-km:"; + } + + Layout layout = Layout.builder( title ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); // Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) // .name( String.format( legendFormat, yName ) ) @@ -482,13 +507,15 @@ public Figure createFigureFzkmDiffVsLanekm(){ } + // ======================================================================================== + // ======================================================================================== public Figure createFigureNkvVsDtv(){ String xName = Headers.VERKEHRSBELASTUNG_PLANFALL; Axis xAxis = Axis.builder().title(xName).build(); Table table2 = table.sortAscendingOn( xName ); // cannot remember why this is necessary - String yName = Headers.NKV_INDUZ_CO2_CONSTRUCTION_CAPPED5; + String yName = Headers.NKV_EL03_CO2_CONSTRUCTION_CAPPED5; Axis yAxis = Axis.builder().title( yName ).build(); // cannot use a a logarithmic y axis since it removes nkv < 1 String title = "nkv_nb normally low; nkv_knotenpunkt normally high; nkv_ew depends on dtv"; @@ -506,8 +533,10 @@ public Figure createFigureNkvVsDtv(){ return new Figure( layout, traceCyan, traceMagenta, traceOrange, traceRed, trace4 ); } + // ======================================================================================== + // ======================================================================================== public Figure createFigureCostVsNkvNew(){ - String xName = Headers.NKV_INDUZ_CO2215_CONSTRUCTION_CAPPED5; + String xName = Headers.NKV_EL03_CO2_215_CONSTRUCTION_CAPPED5; Axis xAxis = Axis.builder().title(xName).autoRange( Axis.AutoRange.REVERSED ) .showZeroLine( false ) @@ -540,8 +569,10 @@ public Figure createFigureCostVsNkvNew(){ , trace4 ); } + // ======================================================================================== + // ======================================================================================== public Figure createFigureCO2VsNkvNew(){ - String xName = Headers.NKV_INDUZ_CO2215_CONSTRUCTION_CAPPED5; + String xName = Headers.NKV_EL03_CO2_215_CONSTRUCTION_CAPPED5; Axis xAxis = Axis.builder().title(xName).autoRange( Axis.AutoRange.REVERSED ) .showZeroLine( false ) @@ -574,6 +605,8 @@ public Figure createFigureCO2VsNkvNew(){ , trace4 ); } + // ======================================================================================== + // ======================================================================================== public Figure createFigureCostVsNkvOld(){ String xName = Headers.NKV_ORIG_CAPPED5; @@ -614,11 +647,15 @@ public Figure createFigureCostVsNkvOld(){ , trace4 ); } + // ======================================================================================== + // ======================================================================================== + // "BubblePlot" handles categorical variables --> could convert BAUTYP into the categories that are of interest. // There is also ScatterPlot3D // one can combine the four methods below by setting the marker color etc. to a Column instead of to a single value. See examples in BubblePlot. // (however, in the end this does not work that much differently from what follows here except that it loops over the categorical column instead of repeating the code) + private static Trace getTraceRed( Table table, String xName, String y2Name ){ Table tableVbe = table.where( table.stringColumn( Headers.BAUTYP ).isIn( "EW8" ) ); final String nameInLegend = "EW8"; diff --git a/src/main/java/org/tub/vsp/bvwp/users/kn/RunLocalCsvScrapingKN.java b/src/main/java/org/tub/vsp/bvwp/users/kn/RunLocalCsvScrapingKN.java index d4e1d77..433bda9 100644 --- a/src/main/java/org/tub/vsp/bvwp/users/kn/RunLocalCsvScrapingKN.java +++ b/src/main/java/org/tub/vsp/bvwp/users/kn/RunLocalCsvScrapingKN.java @@ -52,7 +52,7 @@ public static void main(String[] args) throws IOException{ List allStreetBaseData = scraper .extractAllLocalBaseData( "./data/street/all", "A", ".*" ) .stream() - .map( streetBaseDataContainer -> new StreetAnalysisDataContainer( streetBaseDataContainer, 0.3, constructionCostFactor ) ) + .map( streetBaseDataContainer -> new StreetAnalysisDataContainer( streetBaseDataContainer, constructionCostFactor ) ) .toList(); logger.info( "Writing csv" ); @@ -72,14 +72,14 @@ public static void main(String[] args) throws IOException{ FiguresKN figures = new FiguresKN( table ); String page = MultiPlotUtils.pageTop + System.lineSeparator() + - figures.createFigureFzkmNewVsLanekm().asJavascript( "plot1" ) + System.lineSeparator() + + figures.createFigureFzkmNew().asJavascript( "plot1" ) + System.lineSeparator() + figures.createFigureElasticities().asJavascript( "plot2" ) + System.lineSeparator() + - figures.createFigureFzkmDiffVsLanekm().asJavascript( "plot3" ) + System.lineSeparator() + - figures.createFigureCO2VsLanekm().asJavascript( "plot4" ) + System.lineSeparator() + + figures.createFigureFzkmDiff().asJavascript( "plot3" ) + System.lineSeparator() + + figures.createFigureCO2().asJavascript( "plot4" ) + System.lineSeparator() + figures.createFigureCostVsLanekm().asJavascript( "plot5" ) + System.lineSeparator() + figures.createFigureNkvVsLanekm().asJavascript( "plot6" ) + System.lineSeparator() + figures.createFigureDtv().asJavascript( "plot7" ) + System.lineSeparator() + - figures.createFigureFzkmNewVsLanekm().asJavascript( "plot8" ) + System.lineSeparator() + + figures.createFigureFzkmNew().asJavascript( "plot8" ) + System.lineSeparator() + figures.createFigureNkvVsDtv().asJavascript( "plotA" ) + System.lineSeparator() + figures.createFigureCostVsNkvOld().asJavascript( "plotB" ) + System.lineSeparator() + figures.createFigureCostVsNkvNew().asJavascript( "plotC" ) + System.lineSeparator() + @@ -106,7 +106,7 @@ public static void main(String[] args) throws IOException{ format.setMaximumFractionDigits( 0 ); table.numberColumn( Headers.CO2_COST_NEU ).setPrintFormatter( format, "n/a" ); - Table table2 = table.where( table.numberColumn( Headers.NKV_INDUZ_CO2_CONSTRUCTION ).isLessThan( 1. ) ); + Table table2 = table.where( table.numberColumn( Headers.NKV_EL03_CO2_CONSTRUCTION ).isLessThan( 1. ) ); System.out.println(BvwpUtils.SEPARATOR); System.out.println( table.summarize( Headers.NKV_ORIG, count ).by(Headers.EINSTUFUNG ).print() ); diff --git a/src/test/java/org/tub/vsp/bvwp/io/StreetCsvWriterTest.java b/src/test/java/org/tub/vsp/bvwp/io/StreetCsvWriterTest.java index 70ab838..2e2ef93 100644 --- a/src/test/java/org/tub/vsp/bvwp/io/StreetCsvWriterTest.java +++ b/src/test/java/org/tub/vsp/bvwp/io/StreetCsvWriterTest.java @@ -21,7 +21,7 @@ void testWriteCsv() throws IOException { StreetBaseDataContainer deserializedContainer = jsonIo.readJson(filePath, StreetBaseDataContainer.class); StreetCsvWriter csvWriter = new StreetCsvWriter("output/a20.csv"); - csvWriter.writeCsv(List.of(new StreetAnalysisDataContainer(deserializedContainer, 0.6, 1. ) ) ); + csvWriter.writeCsv(List.of(new StreetAnalysisDataContainer(deserializedContainer, 1. ) ) ); Assertions.assertTrue( FileUtils.contentEqualsIgnoreEOL(FileUtils.getFile("src/test/resources/testData/referenceData/a20.csv"),