The following document contains the results of PMD's CPD 6.4.0.
File | Line |
---|---|
org\opentrafficsim\core\units\distributions\ContinuousDistDoubleScalar.java | 173 |
org\opentrafficsim\core\units\distributions\DiscreteDistDoubleScalar.java | 172 |
public Rel(final double constant, final U unit) { super(constant, unit); } /** * @return a drawn number from the distribution in the given unit. */ @SuppressWarnings({ "unchecked", "rawtypes" }) public T draw() { switch (getUnit().getClass().getSimpleName()) { case "AccelerationUnit": return (T) new Acceleration(getDistribution().draw(), (AccelerationUnit) getUnit()); case "AngleUnit": return (T) new Angle(getDistribution().draw(), (AngleUnit) getUnit()); case "AngleSolidUnit": return (T) new AngleSolid(getDistribution().draw(), (AngleSolidUnit) getUnit()); case "AreaUnit": return (T) new Area(getDistribution().draw(), (AreaUnit) getUnit()); case "DensityUnit": return (T) new Density(getDistribution().draw(), (DensityUnit) getUnit()); case "DimensionlessUnit": return (T) new Dimensionless(getDistribution().draw(), (DimensionlessUnit) getUnit()); case "DurationUnit": return (T) new Duration(getDistribution().draw(), (DurationUnit) getUnit()); case "ElectricalChargeUnit": return (T) new ElectricalCharge(getDistribution().draw(), (ElectricalChargeUnit) getUnit()); case "ElectricalCurrentUnit": return (T) new ElectricalCurrent(getDistribution().draw(), (ElectricalCurrentUnit) getUnit()); case "ElectricalPotentialUnit": return (T) new ElectricalPotential(getDistribution().draw(), (ElectricalPotentialUnit) getUnit()); case "ElectricalResistanceUnit": return (T) new ElectricalResistance(getDistribution().draw(), (ElectricalResistanceUnit) getUnit()); case "EnergyUnit": return (T) new Energy(getDistribution().draw(), (EnergyUnit) getUnit()); case "FlowMassUnit": return (T) new FlowMass(getDistribution().draw(), (FlowMassUnit) getUnit()); case "FlowVolumeUnit": return (T) new FlowVolume(getDistribution().draw(), (FlowVolumeUnit) getUnit()); case "ForceUnit": return (T) new Force(getDistribution().draw(), (ForceUnit) getUnit()); case "FrequencyUnit": return (T) new Frequency(getDistribution().draw(), (FrequencyUnit) getUnit()); case "LengthUnit": return (T) new Length(getDistribution().draw(), (LengthUnit) getUnit()); case "LinearDensityUnit": return (T) new LinearDensity(getDistribution().draw(), (LinearDensityUnit) getUnit()); case "MassUnit": return (T) new Mass(getDistribution().draw(), (MassUnit) getUnit()); case "PowerUnit": return (T) new Power(getDistribution().draw(), (PowerUnit) getUnit()); case "PressureUnit": return (T) new Pressure(getDistribution().draw(), (PressureUnit) getUnit()); case "SpeedUnit": return (T) new Speed(getDistribution().draw(), (SpeedUnit) getUnit()); case "TemperatureUnit": return (T) new Temperature(getDistribution().draw(), (TemperatureUnit) getUnit()); case "TorqueUnit": return (T) new Torque(getDistribution().draw(), (TorqueUnit) getUnit()); case "VolumeUnit": return (T) new Volume(getDistribution().draw(), (VolumeUnit) getUnit()); default: return (T) new DoubleScalar.Rel(getDistribution().draw(), getUnit()); } } /** {@inheritDoc} */ @Override public String toString() { return "ContinuousDistDoubleScalar.Rel [T=" + getUnit().getClass().getSimpleName() + "]"; |
File | Line |
---|---|
org\opentrafficsim\core\units\distributions\ContinuousDistFloatScalar.java | 202 |
org\opentrafficsim\core\units\distributions\DiscreteDistFloatScalar.java | 201 |
return (T) new FloatDimensionless((float) getDistribution().draw(), (DimensionlessUnit) getUnit()); case "DurationUnit": return (T) new FloatDuration((float) getDistribution().draw(), (DurationUnit) getUnit()); case "ElectricalChargeUnit": return (T) new FloatElectricalCharge((float) getDistribution().draw(), (ElectricalChargeUnit) getUnit()); case "ElectricalCurrentUnit": return (T) new FloatElectricalCurrent((float) getDistribution().draw(), (ElectricalCurrentUnit) getUnit()); case "ElectricalPotentialUnit": return (T) new FloatElectricalPotential((float) getDistribution().draw(), (ElectricalPotentialUnit) getUnit()); case "ElectricalResistanceUnit": return (T) new FloatElectricalResistance((float) getDistribution().draw(), (ElectricalResistanceUnit) getUnit()); case "EnergyUnit": return (T) new FloatEnergy((float) getDistribution().draw(), (EnergyUnit) getUnit()); case "FlowMassUnit": return (T) new FloatFlowMass((float) getDistribution().draw(), (FlowMassUnit) getUnit()); case "FlowVolumeUnit": return (T) new FloatFlowVolume((float) getDistribution().draw(), (FlowVolumeUnit) getUnit()); case "ForceUnit": return (T) new FloatForce((float) getDistribution().draw(), (ForceUnit) getUnit()); case "FrequencyUnit": return (T) new FloatFrequency((float) getDistribution().draw(), (FrequencyUnit) getUnit()); case "LengthUnit": return (T) new FloatLength((float) getDistribution().draw(), (LengthUnit) getUnit()); case "LinearDensityUnit": return (T) new FloatLinearDensity((float) getDistribution().draw(), (LinearDensityUnit) getUnit()); case "MassUnit": return (T) new FloatMass((float) getDistribution().draw(), (MassUnit) getUnit()); case "PowerUnit": return (T) new FloatPower((float) getDistribution().draw(), (PowerUnit) getUnit()); case "PressureUnit": return (T) new FloatPressure((float) getDistribution().draw(), (PressureUnit) getUnit()); case "SpeedUnit": return (T) new FloatSpeed((float) getDistribution().draw(), (SpeedUnit) getUnit()); case "TemperatureUnit": return (T) new FloatTemperature((float) getDistribution().draw(), (TemperatureUnit) getUnit()); case "TorqueUnit": return (T) new FloatTorque((float) getDistribution().draw(), (TorqueUnit) getUnit()); case "VolumeUnit": return (T) new FloatVolume((float) getDistribution().draw(), (VolumeUnit) getUnit()); default: return (T) new FloatScalar.Rel((float) getDistribution().draw(), getUnit()); |
File | Line |
---|---|
org\opentrafficsim\core\geometry\OTSBufferingJTS.java | 502 |
org\opentrafficsim\core\geometry\OTSLine3D.java | 313 |
ArrayList<Coordinate> out = new ArrayList<Coordinate>(); Coordinate[] firstCoordinates = startGeometry.getCoordinates(); Coordinate[] secondCoordinates = endGeometry.getCoordinates(); int firstIndex = 0; int secondIndex = 0; Coordinate prevCoordinate = null; final double tooClose = 0.05; // 5 cm while (firstIndex < firstCoordinates.length && secondIndex < secondCoordinates.length) { double firstRatio = firstIndex < firstCoordinates.length ? first.indexOf(firstCoordinates[firstIndex]) / firstLength : Double.MAX_VALUE; double secondRatio = secondIndex < secondCoordinates.length ? second.indexOf(secondCoordinates[secondIndex]) / secondLength : Double.MAX_VALUE; double ratio; if (firstRatio < secondRatio) { ratio = firstRatio; firstIndex++; } else { ratio = secondRatio; secondIndex++; } Coordinate firstCoordinate = first.extractPoint(ratio * firstLength); Coordinate secondCoordinate = second.extractPoint(ratio * secondLength); Coordinate resultCoordinate = new Coordinate((1 - ratio) * firstCoordinate.x + ratio * secondCoordinate.x, (1 - ratio) * firstCoordinate.y + ratio * secondCoordinate.y); if (null == prevCoordinate || resultCoordinate.distance(prevCoordinate) > tooClose) { out.add(resultCoordinate); prevCoordinate = resultCoordinate; } } Coordinate[] resultCoordinates = new Coordinate[out.size()]; for (int index = 0; index < out.size(); index++) { resultCoordinates[index] = out.get(index); } return new OTSLine3D(resultCoordinates); } /** * @param args String[]; args * @throws NetworkException on error * @throws OTSGeometryException on error */ public static void main(final String[] args) throws NetworkException, OTSGeometryException |
File | Line |
---|---|
org\opentrafficsim\core\geometry\OTSBufferingJTS.java | 298 |
org\opentrafficsim\core\geometry\OTSPoint3D.java | 170 |
private static OTSPoint3D intersectionOfLineSegments(final OTSPoint3D line1P1, final OTSPoint3D line1P2, final OTSPoint3D line2P1, final OTSPoint3D line2P2) { double denominator = (line2P2.y - line2P1.y) * (line1P2.x - line1P1.x) - (line2P2.x - line2P1.x) * (line1P2.y - line1P1.y); if (denominator == 0f) { return null; // lines are parallel (they might even be on top of each other, but we don't check that) } double uA = ((line2P2.x - line2P1.x) * (line1P1.y - line2P1.y) - (line2P2.y - line2P1.y) * (line1P1.x - line2P1.x)) / denominator; if ((uA < 0f) || (uA > 1f)) { return null; // intersection outside line 1 } double uB = ((line1P2.x - line1P1.x) * (line1P1.y - line2P1.y) - (line1P2.y - line1P1.y) * (line1P1.x - line2P1.x)) / denominator; if (uB < 0 || uB > 1) { return null; // intersection outside line 2 } return new OTSPoint3D(line1P1.x + uA * (line1P2.x - line1P1.x), line1P1.y + uA * (line1P2.y - line1P1.y), 0); } |
File | Line |
---|---|
org\opentrafficsim\core\dsol\OTSDEVSRTParallelMove.java | 298 |
org\opentrafficsim\core\dsol\OTSDEVSRTParallelMove.java | 341 |
new SimEvent<>(this.simulatorTime, se.getSource(), se.getTarget(), "movePrep", se.getArgs()); this.executor.execute(new Runnable() { @Override public void run() { try { moveEvent.execute(); } catch (Exception exception) { SimLogger.always().error(exception); if (OTSDEVSRTParallelMove.this.isPauseOnError()) { try { OTSDEVSRTParallelMove.this.stop(); } catch (SimRuntimeException exception1) { SimLogger.always().error(exception1); } } } } }); } this.executor.shutdown(); try { this.executor.awaitTermination(1L, java.util.concurrent.TimeUnit.HOURS); } catch (InterruptedException exception) { // } this.executor = Executors.newFixedThreadPool(1); for (int i = 0; i < moveEvents.size(); i++) { SimEvent<SimTimeDoubleUnit> se = (SimEvent<SimTimeDoubleUnit>) moveEvents.get(i); final SimEventInterface<SimTimeDoubleUnit> moveEvent = new SimEvent<>(this.simulatorTime, se.getSource(), se.getTarget(), "moveGenerate", se.getArgs()); |
File | Line |
---|---|
org\opentrafficsim\core\units\distributions\ContinuousDistFloatScalar.java | 173 |
org\opentrafficsim\core\units\distributions\DiscreteDistFloatScalar.java | 172 |
public Rel(final float constant, final U unit) { super(constant, unit); } /** * @return a drawn number from the distribution in the given unit. */ @SuppressWarnings({ "unchecked", "rawtypes" }) public final T draw() { switch (getUnit().getClass().getSimpleName()) { case "AccelerationUnit": return (T) new FloatAcceleration((float) getDistribution().draw(), (AccelerationUnit) getUnit()); case "AngleUnit": return (T) new FloatAngle((float) getDistribution().draw(), (AngleUnit) getUnit()); case "AngleSolidUnit": return (T) new FloatAngleSolid((float) getDistribution().draw(), (AngleSolidUnit) getUnit()); case "AreaUnit": return (T) new FloatArea((float) getDistribution().draw(), (AreaUnit) getUnit()); case "DensityUnit": return (T) new FloatDensity((float) getDistribution().draw(), (DensityUnit) getUnit()); case "DimensionlessUnit": return (T) new FloatDimensionless((float) getDistribution().draw(), (DimensionlessUnit) getUnit()); |
File | Line |
---|---|
org\opentrafficsim\core\geometry\OTSBufferingJTS.java | 509 |
org\opentrafficsim\core\geometry\OTSLine3D.java | 320 |
org\opentrafficsim\core\geometry\OTSLine3D.java | 390 |
while (firstIndex < firstCoordinates.length && secondIndex < secondCoordinates.length) { double firstRatio = firstIndex < firstCoordinates.length ? first.indexOf(firstCoordinates[firstIndex]) / firstLength : Double.MAX_VALUE; double secondRatio = secondIndex < secondCoordinates.length ? second.indexOf(secondCoordinates[secondIndex]) / secondLength : Double.MAX_VALUE; double ratio; if (firstRatio < secondRatio) { ratio = firstRatio; firstIndex++; } else { ratio = secondRatio; secondIndex++; } Coordinate firstCoordinate = first.extractPoint(ratio * firstLength); Coordinate secondCoordinate = second.extractPoint(ratio * secondLength); Coordinate resultCoordinate = new Coordinate((1 - ratio) * firstCoordinate.x + ratio * secondCoordinate.x, (1 - ratio) * firstCoordinate.y + ratio * secondCoordinate.y); if (null == prevCoordinate || resultCoordinate.distance(prevCoordinate) > tooClose) { out.add(resultCoordinate); prevCoordinate = resultCoordinate; } } |
File | Line |
---|---|
org\opentrafficsim\core\units\distributions\ContinuousDistFloatScalar.java | 109 |
org\opentrafficsim\core\units\distributions\DiscreteDistFloatScalar.java | 109 |
public Abs(final float constant, final AU unit) { super(constant, unit); } /** * @return a drawn number from the distribution in the given unit. */ @SuppressWarnings({ "unchecked", "rawtypes" }) public final T draw() { switch (getUnit().getClass().getSimpleName()) { case "DirectionUnit": return (T) new FloatDirection((float) getDistribution().draw(), (DirectionUnit) getUnit()); case "PositionUnit": return (T) new FloatPosition((float) getDistribution().draw(), (PositionUnit) getUnit()); case "AbsoluteTemperatureUnit": return (T) new FloatAbsoluteTemperature((float) getDistribution().draw(), (AbsoluteTemperatureUnit) getUnit()); case "TimeUnit": return (T) new FloatTime((float) getDistribution().draw(), (TimeUnit) getUnit()); default: return (T) new FloatScalar.Abs((float) getDistribution().draw(), (AU) getUnit()); |
File | Line |
---|---|
org\opentrafficsim\core\geometry\Test.java | 172 |
org\opentrafficsim\core\geometry\Test.java | 919 |
reference = new OTSLine3D(new OTSPoint3D(10, 10, 0), new OTSPoint3D(9.999, 8, 0), new OTSPoint3D(9.996, 7.99, 0), new OTSPoint3D(9.999, 7.98, 0), new OTSPoint3D(10.03, 7.95, 0), new OTSPoint3D(10.01, 7.94, 0), new OTSPoint3D(10.0, 7.94, 0), new OTSPoint3D(10, 6, 0), new OTSPoint3D(9.999, 6, 0), new OTSPoint3D(9.996, 5.99, 0), new OTSPoint3D(9.999, 5.98, 0), new OTSPoint3D(10.03, 5.95, 0), new OTSPoint3D(10.01, 5.94, 0), new OTSPoint3D(10.0, 5.94, 0), new OTSPoint3D(10, 2, 0)); System.out.println("AV line2: " + checkAll(reference, 1.625)); |
File | Line |
---|---|
org\opentrafficsim\core\network\OTSNetwork.java | 633 |
org\opentrafficsim\core\network\OTSNetwork.java | 684 |
for (LinkEdge<Link> link : path.getEdgeList()) { if (!link.getLink().getEndNode().equals(route.destinationNode()) && route.destinationNode().isDirectionallyConnectedTo(gtuType, link.getLink().getEndNode())) { route.addNode(link.getLink().getEndNode()); } else if (!link.getLink().getStartNode().equals(route.destinationNode()) && route.destinationNode().isDirectionallyConnectedTo(gtuType, link.getLink().getStartNode())) { route.addNode(link.getLink().getStartNode()); } else { throw new NetworkException("Cannot connect two links when calculating shortest route"); |
File | Line |
---|---|
org\opentrafficsim\core\dsol\OTSDEVSRTParallelMove.java | 298 |
org\opentrafficsim\core\dsol\OTSDEVSRTParallelMove.java | 341 |
org\opentrafficsim\core\dsol\OTSDEVSRTParallelMove.java | 384 |
new SimEvent<>(this.simulatorTime, se.getSource(), se.getTarget(), "movePrep", se.getArgs()); this.executor.execute(new Runnable() { @Override public void run() { try { moveEvent.execute(); } catch (Exception exception) { SimLogger.always().error(exception); if (OTSDEVSRTParallelMove.this.isPauseOnError()) { try { OTSDEVSRTParallelMove.this.stop(); } catch (SimRuntimeException exception1) { SimLogger.always().error(exception1); } } } } }); } this.executor.shutdown(); try { this.executor.awaitTermination(1L, java.util.concurrent.TimeUnit.HOURS); } catch (InterruptedException exception) { // } |
File | Line |
---|---|
org\opentrafficsim\core\geometry\Test.java | 955 |
org\opentrafficsim\core\geometry\Test2.java | 40 |
System.out.println(OTSGeometryUtil.printCoordinates("#left:\nc0,0,1\n#", left, "\n ")); reference = new OTSLine3D(new OTSPoint3D(10, 0.5, 0), new OTSPoint3D(10, -2, 0), new OTSPoint3D(9.9, -2.01, 0), new OTSPoint3D(10.1, -2.03, 0), new OTSPoint3D(10, -2.04, 0), new OTSPoint3D(10, -6, 0), new OTSPoint3D(9.9, -6.01, 0), new OTSPoint3D(10.1, -6.03, 0), new OTSPoint3D(10, -6.04, 0), new OTSPoint3D(10, -8.54, 0)); System.out.println(OTSGeometryUtil.printCoordinates("#reference:\nc1,0,0\n#", reference, "\n ")); |
File | Line |
---|---|
org\opentrafficsim\core\geometry\Test.java | 154 |
org\opentrafficsim\core\geometry\Test.java | 946 |
reference = new OTSLine3D(new OTSPoint3D(5, -1, 0), new OTSPoint3D(5, -2, 0), new OTSPoint3D(4.9, -2.01, 0), new OTSPoint3D(5.1, -2.03, 0), new OTSPoint3D(5, -2.04, 0), new OTSPoint3D(5, -6, 0), new OTSPoint3D(4.9, -6.01, 0), new OTSPoint3D(5.1, -6.03, 0), new OTSPoint3D(5, -6.04, 0), new OTSPoint3D(5, -7.04, 0)); System.out.println("Straight reference with noise near ends: " + checkAll(reference, 2)); |
File | Line |
---|---|
org\opentrafficsim\core\units\distributions\ContinuousDistDoubleScalar.java | 126 |
org\opentrafficsim\core\units\distributions\DiscreteDistDoubleScalar.java | 125 |
case "PositionUnit": return (T) new Position(getDistribution().draw(), (PositionUnit) getUnit()); case "AbsoluteTemperatureUnit": return (T) new AbsoluteTemperature(getDistribution().draw(), (AbsoluteTemperatureUnit) getUnit()); case "TimeUnit": return (T) new Time(getDistribution().draw(), (TimeUnit) getUnit()); default: return (T) new DoubleScalar.Abs(getDistribution().draw(), (AU) getUnit()); } } /** {@inheritDoc} */ @Override public String toString() { return "ContinuousDistDoubleScalar.Abs [T=" + getUnit().getClass().getSimpleName() + "]"; |
File | Line |
---|---|
org\opentrafficsim\core\dsol\OTSAnimator.java | 63 |
org\opentrafficsim\core\dsol\OTSSimulator.java | 60 |
OTSReplication newReplication = OTSReplication.create("rep" + replicationnr, startTime, warmupPeriod, runLength, model); super.initialize(newReplication, ReplicationMode.TERMINATING); } /** {@inheritDoc} */ @Override public final SimEvent<SimTimeDoubleUnit> scheduleEvent(final Time executionTime, final short priority, final Object source, final Object target, final String method, final Object[] args) throws SimRuntimeException { SimEvent<SimTimeDoubleUnit> result = new SimEvent<>( new SimTimeDoubleUnit(new Time(executionTime.getSI(), TimeUnit.BASE)), priority, source, target, method, args); scheduleEvent(result); return result; } /** {@inheritDoc} */ @Override public final OTSReplication getReplication() |
File | Line |
---|---|
org\opentrafficsim\core\geometry\OTSBufferingJTS.java | 211 |
org\opentrafficsim\core\geometry\OTSOffsetLinePK.java | 148 |
for (int additionalPoint = 1; additionalPoint < numSegments; additionalPoint++) { double intermediateAngle = (additionalPoint * angle + (numSegments - additionalPoint) * prevAngle) / numSegments; if (prevAngle * angle < 0 && Math.abs(prevAngle) > Math.PI / 2 && Math.abs(angle) > Math.PI / 2) { intermediateAngle += Math.PI; } OTSPoint3D intermediatePoint = new OTSPoint3D(prevPoint.x - Math.sin(intermediateAngle) * offset, prevPoint.y + Math.cos(intermediateAngle) * offset); |
File | Line |
---|---|
org\opentrafficsim\core\geometry\Test.java | 145 |
org\opentrafficsim\core\geometry\Test.java | 165 |
System.out.println("Closely spaced points on large circle: " + checkAll(reference, 2)); // Straight design line with some <i>noise</i> (sufficiently far from the end points). reference = new OTSLine3D(new OTSPoint3D(10, 10, 0), new OTSPoint3D(9.999, 8, 0), new OTSPoint3D(9.996, 7.99, 0), new OTSPoint3D(9.999, 7.98, 0), new OTSPoint3D(10.03, 7.95, 0), new OTSPoint3D(10.01, 7.94, 0), new OTSPoint3D(10.0, 7.94, 0), new OTSPoint3D(10, 6, 0), new OTSPoint3D(10, 2, 0)); System.out.println("Straight reference with noise far from ends: " + checkAll(reference, 2)); |
File | Line |
---|---|
org\opentrafficsim\core\geometry\Test.java | 898 |
org\opentrafficsim\core\geometry\Test.java | 916 |
public static void test6() throws OTSGeometryException { System.out.println("O0,-10"); OTSLine3D reference = new OTSLine3D(new OTSPoint3D(10, 10, 0), new OTSPoint3D(9.999, 8, 0), new OTSPoint3D(9.996, 7.99, 0), new OTSPoint3D(9.999, 7.98, 0), new OTSPoint3D(10.03, 7.95, 0), new OTSPoint3D(10.01, 7.94, 0), new OTSPoint3D(10.0, 7.94, 0), new OTSPoint3D(10, 6, 0), new OTSPoint3D(10, 2, 0)); |
File | Line |
---|---|
org\opentrafficsim\core\geometry\Test.java | 148 |
org\opentrafficsim\core\geometry\Test.java | 167 |
org\opentrafficsim\core\geometry\Test.java | 901 |
reference = new OTSLine3D(new OTSPoint3D(10, 10, 0), new OTSPoint3D(9.999, 8, 0), new OTSPoint3D(9.996, 7.99, 0), new OTSPoint3D(9.999, 7.98, 0), new OTSPoint3D(10.03, 7.95, 0), new OTSPoint3D(10.01, 7.94, 0), new OTSPoint3D(10.0, 7.94, 0), new OTSPoint3D(10, 6, 0), new OTSPoint3D(10, 2, 0)); System.out.println("Straight reference with noise far from ends: " + checkAll(reference, 2)); |
File | Line |
---|---|
org\opentrafficsim\core\network\OTSNode.java | 188 |
org\opentrafficsim\core\network\OTSNode.java | 251 |
} // ------------------------------------------- make datasets if needed if (this.connections == null) { this.connections = new HashMap<>(); } if (!this.connections.containsKey(gtuType)) { this.connections.put(gtuType, new HashMap<>()); } Map<Link, Set<Link>> gtuMap = this.connections.get(gtuType); if (!gtuMap.containsKey(incomingLink)) { gtuMap.put(incomingLink, new HashSet<>()); } // ------------------------------------------- add the connection gtuMap.get(incomingLink).add(outgoingLink); |