EvaluateAttenuationCnossos { public static double dbaToW(double dBA) { return Math.pow(10., dBA / 10.); }  void setaGlobal(double[] aGlobal); void setFreq_lambda(double[] freq_lambda); static double dbaToW(double dBA); static double wToDba(double w); double[] getaGlobal(); boolean isgToSigma(); void setgToSigma(boolean gToSigma); double[] getDeltaDif(SegmentPath srpath, PropagationProcessPathData data); static double getADiv(double distance); static double getAAtm(double dist, double alpha_atmo); static double[] getAGroundCore(PropagationPath path, SegmentPath segmentPath, PropagationProcessPathData data); double getDeltaGround(double aGround, double deltaDifPrim, double deltaDif); double[] getARef(PropagationPath path, PropagationProcessPathData data); double[] getAGround(SegmentPath segmentPath,PropagationPath path, PropagationProcessPathData data); double[] getABoundary(PropagationPath path, PropagationProcessPathData data); double[] evaluate(PropagationPath path, PropagationProcessPathData data);  }
@Test public void TC17() throws LayerDelaunayError, IOException { GeometryFactory factory = new GeometryFactory(); Envelope cellEnvelope = new Envelope(new Coordinate(-250., -250., 0.), new Coordinate(250, 250, 0.)); MeshBuilder mesh = new MeshBuilder(); mesh.addGeometry(factory.createPolygon(new Coordinate[]{ new Coordinate(114, 52, 0), new Coordinate(170, 60, 0), new Coordinate(170, 62, 0), new Coordinate(114, 54, 0), new Coordinate(114, 52, 0)}), 15, new double[]{0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.5}); mesh.addTopographicPoint(new Coordinate(0, 80, 0)); mesh.addTopographicPoint(new Coordinate(225, 80, 0)); mesh.addTopographicPoint(new Coordinate(225, -20, 0)); mesh.addTopographicPoint(new Coordinate(0, -20, 0)); mesh.addTopographicPoint(new Coordinate(120, -20, 0)); mesh.addTopographicPoint(new Coordinate(185, -5, 10)); mesh.addTopographicPoint(new Coordinate(205, -5, 10)); mesh.addTopographicPoint(new Coordinate(205, 75, 10)); mesh.addTopographicPoint(new Coordinate(185, 75, 10)); mesh.addTopographicPoint(new Coordinate(225, 80, 0)); mesh.addTopographicPoint(new Coordinate(225, -20, 0)); mesh.addTopographicPoint(new Coordinate(0, -20, 0)); mesh.addTopographicPoint(new Coordinate(0, 80, 0)); mesh.addTopographicPoint(new Coordinate(120, 80, 0)); mesh.addTopographicPoint(new Coordinate(205, -5, 10)); mesh.addTopographicPoint(new Coordinate(205, 75, 10)); mesh.addTopographicPoint(new Coordinate(185, 75, 10)); mesh.addTopographicPoint(new Coordinate(185, -5, 10)); mesh.finishPolygonFeeding(cellEnvelope); FastObstructionTest manager = new FastObstructionTest(mesh.getPolygonWithHeight(), mesh.getTriangles(), mesh.getTriNeighbors(), mesh.getVertices()); DirectPropagationProcessData rayData = new DirectPropagationProcessData(manager); rayData.addReceiver(new Coordinate(200, 50, 11.5)); PropagationProcessPathData attData = new PropagationProcessPathData(); rayData.addSource(factory.createPoint(new Coordinate(10, 10, 1)), ComputeRays.dbaToW(aWeighting(Collections.nCopies(attData.freq_lvl.size(), 93d)))); rayData.setComputeHorizontalDiffraction(true); rayData.addSoilType(new GeoWithSoilType(factory.toGeometry(new Envelope(0, 50, -100, 100)), 0.9)); rayData.addSoilType(new GeoWithSoilType(factory.toGeometry(new Envelope(50, 150, -100, 100)), 0.5)); rayData.addSoilType(new GeoWithSoilType(factory.toGeometry(new Envelope(150, 225, -100, 100)), 0.2)); rayData.setComputeVerticalDiffraction(true); rayData.setGs(0.9); attData.setHumidity(70); attData.setTemperature(10); attData.setPrime2520(false); ComputeRaysOut propDataOut = new RayOut(true, attData, rayData); ComputeRays computeRays = new ComputeRays(rayData); computeRays.setThreadCount(1); computeRays.run(propDataOut); assertArrayEquals( new double[]{14.02,23.84,30.95,33.86,38.37,38.27,33.25,15.28}, propDataOut.getVerticesSoundLevel().get(0).value, ERROR_EPSILON_high); }
@Test public void testSourceLines() throws LayerDelaunayError, IOException, ParseException { GeometryFactory factory = new GeometryFactory(); WKTReader wktReader = new WKTReader(factory); LineString geomSource = (LineString)wktReader.read("LINESTRING (51 40.5 0.05, 51 55.5 0.05)"); Envelope cellEnvelope = new Envelope(new Coordinate(-1200, -1200, 0.), new Coordinate(1200, 1200, 0.)); MeshBuilder mesh = new MeshBuilder(); mesh.finishPolygonFeeding(cellEnvelope); FastObstructionTest manager = new FastObstructionTest(mesh.getPolygonWithHeight(), mesh.getTriangles(), mesh.getTriNeighbors(), mesh.getVertices()); double[] roadLvl = new double[]{25.65, 38.15, 54.35, 60.35, 74.65, 66.75, 59.25, 53.95}; for(int i = 0; i < roadLvl.length; i++) { roadLvl[i] = ComputeRays.dbaToW(roadLvl[i]); } DirectPropagationProcessData rayData = new DirectPropagationProcessData(manager); rayData.addReceiver(new Coordinate(50, 50, 0.05)); rayData.addReceiver(new Coordinate(48, 50, 4)); rayData.addReceiver(new Coordinate(44, 50, 4)); rayData.addReceiver(new Coordinate(40, 50, 4)); rayData.addReceiver(new Coordinate(20, 50, 4)); rayData.addReceiver(new Coordinate(0, 50, 4)); List<Coordinate> srcPtsRef = new ArrayList<>(); ComputeRays.splitLineStringIntoPoints(geomSource, 1.0, srcPtsRef); for(Coordinate srcPtRef : srcPtsRef) { rayData.addSource(factory.createPoint(srcPtRef), roadLvl); } rayData.setComputeHorizontalDiffraction(true); rayData.addSoilType(new GeoWithSoilType(factory.toGeometry(new Envelope(0, 50, -250, 250)), 0.9)); rayData.addSoilType(new GeoWithSoilType(factory.toGeometry(new Envelope(50, 150, -250, 250)), 0.5)); rayData.addSoilType(new GeoWithSoilType(factory.toGeometry(new Envelope(150, 225, -250, 250)), 0.2)); rayData.setComputeVerticalDiffraction(true); rayData.maxSrcDist = 2000; PropagationProcessPathData attData = new PropagationProcessPathData(); attData.setHumidity(70); attData.setTemperature(10); RayOut propDataOut = new RayOut(true, attData, rayData); ComputeRays computeRays = new ComputeRays(rayData); computeRays.makeRelativeZToAbsolute(); computeRays.setThreadCount(1); computeRays.run(propDataOut); rayData.clearSources(); rayData.addSource(geomSource, roadLvl); RayOut propDataOutTest = new RayOut(true, attData, rayData); computeRays.run(propDataOutTest); Map<Long, double[]> levelsPerReceiver = new HashMap<>(); for(ComputeRaysOut.VerticeSL lvl : propDataOut.receiversAttenuationLevels) { if(!levelsPerReceiver.containsKey(lvl.receiverId)) { levelsPerReceiver.put(lvl.receiverId, lvl.value); } else { levelsPerReceiver.put(lvl.receiverId, ComputeRays.sumDbArray(levelsPerReceiver.get(lvl.receiverId), lvl.value)); } } Map<Long, double[]> levelsPerReceiverLines = new HashMap<>(); for(ComputeRaysOut.VerticeSL lvl : propDataOutTest.receiversAttenuationLevels) { if(!levelsPerReceiverLines.containsKey(lvl.receiverId)) { levelsPerReceiverLines.put(lvl.receiverId, lvl.value); } else { levelsPerReceiverLines.put(lvl.receiverId, ComputeRays.sumDbArray(levelsPerReceiverLines.get(lvl.receiverId), lvl.value)); } } assertEquals(6, levelsPerReceiverLines.size()); assertEquals(6, levelsPerReceiver.size()); for(int i = 0; i < levelsPerReceiver.size(); i++) { assertArrayEquals(levelsPerReceiver.get(i), levelsPerReceiverLines.get(i), 0.2); } }