CPD Results

The following document contains the results of PMD's CPD 6.4.0.

Duplications

File Line
org\opentrafficsim\road\network\factory\opendrive\ElevationTag.java 63
org\opentrafficsim\road\network\factory\opendrive\SuperElevationTag.java 64
        ElevationTag elevationTag = new ElevationTag();

        Node s = attributes.getNamedItem("s");
        if (s == null)
            throw new SAXException("Geometry: missing attribute s");
        elevationTag.s = new Length(Double.parseDouble(s.getNodeValue().trim()), LengthUnit.METER);

        Node a = attributes.getNamedItem("a");
        if (a == null)
            throw new SAXException("Geometry: missing attribute a");
        elevationTag.a = new Length(Double.parseDouble(a.getNodeValue().trim()), LengthUnit.METER);

        Node b = attributes.getNamedItem("b");
        if (b == null)
            throw new SAXException("Geometry: missing attribute b");
        elevationTag.b = new Length(Double.parseDouble(b.getNodeValue().trim()), LengthUnit.METER);

        Node c = attributes.getNamedItem("c");
        if (c == null)
            throw new SAXException("Geometry: missing attribute c");
        elevationTag.c = new Length(Double.parseDouble(c.getNodeValue().trim()), LengthUnit.METER);

        Node d = attributes.getNamedItem("d");
        if (d == null)
            throw new SAXException("Geometry: missing attribute d");
        elevationTag.d = new Length(Double.parseDouble(d.getNodeValue().trim()), LengthUnit.METER);
File Line
org\opentrafficsim\road\network\factory\opendrive\RoadTag.java 274
org\opentrafficsim\road\network\factory\opendrive\RoadTag.java 342
                        OTSPoint3D point = new OTSPoint3D(currentGeometryTag.x.doubleValue(),
                                currentGeometryTag.y.doubleValue(), currentGeometryTag.z.doubleValue());

                        if (points.size() == 0)
                            points.add(point);
                        else
                        {
                            if (point.x != points.get(points.size() - 1).x && point.y != points.get(points.size() - 1).y)
                                points.add(point);
                        }

                        OTSPoint3D lastPoint = new OTSPoint3D(points.get(points.size() - 1));

                        if (currentGeometryTag.interLine != null)
                        {
                            for (OTSPoint3D point1 : currentGeometryTag.interLine.getPoints())
                            {

                                /*
                                 * double xDiff = lastPoint.x - point.x; double yDiff = lastPoint.y - point.y; double distance =
                                 * (float) Math.sqrt(xDiff * xDiff + yDiff * yDiff);
                                 */

                                if (lastPoint.x != point.x && lastPoint.y != point.y)
                                {
                                    points.add(point1);
                                    lastPoint = point1;
                                }
                            }
                        }
File Line
org\opentrafficsim\road\network\factory\opendrive\RoadTag.java 950
org\opentrafficsim\road\network\factory\opendrive\RoadTag.java 1012
                    if (!openDriveNetworkLaneParser.trafficLightsByLanes.containsKey(roadTag.id))
                    {
                        Set<SimpleTrafficLight> lights = new HashSet<SimpleTrafficLight>();
                        openDriveNetworkLaneParser.trafficLightsByLanes.put(roadTag.id, lights);
                    }

                    openDriveNetworkLaneParser.trafficLightsBySignals.get(signalTag.id).add(trafficLight);
                    openDriveNetworkLaneParser.trafficLightsByLanes.get(roadTag.id).add(trafficLight);

                }
                catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException
                        | IllegalArgumentException | InvocationTargetException exception)
                {
                    throw new NetworkException(
                            "Traffic Light: CLASS NAME " + SimpleTrafficLight.class.getName() + " for " + signalTag.id
                                    + " on lane " + lane.toString() + " -- class not found or constructor not right",
                            exception);
                }
            }
            else if (signalTag.type.equals("206") && signalTag.dynamic.equals("no"))// generate stop sign
            {

            }
            else
                System.err.println("Unknown signals");
File Line
org\opentrafficsim\road\network\factory\opendrive\RoadTag.java 238
org\opentrafficsim\road\network\factory\opendrive\RoadTag.java 273
                    {
                        OTSPoint3D point = new OTSPoint3D(currentGeometryTag.x.doubleValue(),
                                currentGeometryTag.y.doubleValue(), currentGeometryTag.z.doubleValue());

                        if (points.size() == 0)
                            points.add(point);
                        else
                        {
                            if (point.x != points.get(points.size() - 1).x && point.y != points.get(points.size() - 1).y)
                                points.add(point);
                        }

                        OTSPoint3D lastPoint = new OTSPoint3D(points.get(points.size() - 1));

                        if (currentGeometryTag.interLine != null)
                        {
                            for (OTSPoint3D point1 : currentGeometryTag.interLine.getPoints())
                            {
                                // double xDiff = lastPoint.x - point.x;
                                // double yDiff = lastPoint.y - point.y;
                                // double distance = (float) Math.sqrt(xDiff * xDiff + yDiff * yDiff);

                                if (lastPoint.x != point1.x && lastPoint.y != point1.y)
File Line
org\opentrafficsim\road\network\factory\opendrive\RoadTag.java 239
org\opentrafficsim\road\network\factory\opendrive\RoadTag.java 342
                        OTSPoint3D point = new OTSPoint3D(currentGeometryTag.x.doubleValue(),
                                currentGeometryTag.y.doubleValue(), currentGeometryTag.z.doubleValue());

                        if (points.size() == 0)
                            points.add(point);
                        else
                        {
                            if (point.x != points.get(points.size() - 1).x && point.y != points.get(points.size() - 1).y)
                                points.add(point);
                        }

                        OTSPoint3D lastPoint = new OTSPoint3D(points.get(points.size() - 1));

                        if (currentGeometryTag.interLine != null)
                        {
                            for (OTSPoint3D point1 : currentGeometryTag.interLine.getPoints())
                            {
                                // double xDiff = lastPoint.x - point.x;
                                // double yDiff = lastPoint.y - point.y;
                                // double distance = (float) Math.sqrt(xDiff * xDiff + yDiff * yDiff);

                                if (lastPoint.x != point1.x && lastPoint.y != point1.y)
File Line
org\opentrafficsim\road\network\factory\opendrive\Controller.java 133
org\opentrafficsim\road\network\factory\opendrive\Controller.java 154
            for (SimpleTrafficLight light : this.trafficLights.get(6))
            {
                try
                {
                    // System.out.println("traffic light 6 at time " + this.simulator.getSimulatorTime());

                    this.simulator.scheduleEventRel(new Duration(24.0, DurationUnit.SECOND), this, light,
                            "setTrafficLightColor", new Object[] {TrafficLightColor.GREEN});
                    this.simulator.scheduleEventRel(new Duration(39.0, DurationUnit.SECOND), this, light,
                            "setTrafficLightColor", new Object[] {TrafficLightColor.YELLOW});
                    this.simulator.scheduleEventRel(new Duration(48.0, DurationUnit.SECOND), this, light,
                            "setTrafficLightColor", new Object[] {TrafficLightColor.RED});
                }
                catch (SimRuntimeException exception)
                {
                    exception.printStackTrace();
                }
            }
        }
        if (this.trafficLights.containsKey(7))
File Line
org\opentrafficsim\road\network\factory\opendrive\Controller.java 173
org\opentrafficsim\road\network\factory\opendrive\Controller.java 194
            for (SimpleTrafficLight light : this.trafficLights.get(9))
            {
                try
                {
                    // System.out.println("traffic light 9 at time " + this.simulator.getSimulatorTime());

                    this.simulator.scheduleEventRel(new Duration(48.0, DurationUnit.SECOND), this, light,
                            "setTrafficLightColor", new Object[] {TrafficLightColor.GREEN});
                    this.simulator.scheduleEventRel(new Duration(63.0, DurationUnit.SECOND), this, light,
                            "setTrafficLightColor", new Object[] {TrafficLightColor.YELLOW});
                    this.simulator.scheduleEventRel(new Duration(72.0, DurationUnit.SECOND), this, light,
                            "setTrafficLightColor", new Object[] {TrafficLightColor.RED});
                }
                catch (SimRuntimeException exception)
                {
                    exception.printStackTrace();
                }
            }
        }
        if (this.trafficLights.containsKey(10))
File Line
org\opentrafficsim\road\network\factory\opendrive\Controller.java 93
org\opentrafficsim\road\network\factory\opendrive\Controller.java 114
            for (SimpleTrafficLight light : this.trafficLights.get(3))
            {
                try
                {
                    // System.out.println("traffic light 3 at time " + this.simulator.getSimulatorTime() + " is " +
                    // ((TrafficLight) light).getTrafficLightColor().toString());
                    this.simulator.scheduleEventRel(Duration.ZERO, this, light, "setTrafficLightColor",
                            new Object[] {TrafficLightColor.GREEN});
                    this.simulator.scheduleEventRel(new Duration(15.0, DurationUnit.SECOND), this, light,
                            "setTrafficLightColor", new Object[] {TrafficLightColor.YELLOW});
                    this.simulator.scheduleEventRel(new Duration(24.0, DurationUnit.SECOND), this, light,
                            "setTrafficLightColor", new Object[] {TrafficLightColor.RED});
                }
                catch (SimRuntimeException exception)
                {
                    exception.printStackTrace();
                }
            }
        }
        if (this.trafficLights.containsKey(4))
File Line
org\opentrafficsim\road\network\factory\opendrive\RoadTag.java 310
org\opentrafficsim\road\network\factory\opendrive\RoadTag.java 379
                        String sublinkId = roadTag.id + "." + laneSecIndex.toString();
                        CrossSectionLink sublink = new CrossSectionLink(openDriveNetworkLaneParser.network, sublinkId,
                                from.node, to.node, openDriveNetworkLaneParser.network.getLinkType(LinkType.DEFAULTS.ROAD),
                                designLine, simulator, LaneKeepingPolicy.KEEPLANE);

                        roadTag.subLinks.add(sublink);

                        if (!otsNetwork.containsNode(from.node))
                            otsNetwork.addNode(from.node);
                        if (!otsNetwork.containsNode(to.node))
                            otsNetwork.addNode(to.node);

                        if (!otsNetwork.containsLink(sublink))
                            otsNetwork.addLink(sublink);
                        else
                            System.err.println("Sublink already registered: " + sublink);
File Line
org\opentrafficsim\road\network\factory\opendrive\Controller.java 213
org\opentrafficsim\road\network\factory\opendrive\Controller.java 234
            for (SimpleTrafficLight light : this.trafficLights.get(12))
            {
                try
                {
                    // System.out.println("traffic light 12 at time " + this.simulator.getSimulatorTime());

                    this.simulator.scheduleEventRel(new Duration(72.0, DurationUnit.SECOND), this, light,
                            "setTrafficLightColor", new Object[] {TrafficLightColor.GREEN});
                    this.simulator.scheduleEventRel(new Duration(87.0, DurationUnit.SECOND), this, light,
                            "setTrafficLightColor", new Object[] {TrafficLightColor.YELLOW});
                    this.simulator.scheduleEventRel(new Duration(96.0, DurationUnit.SECOND), this, light,
                            "setTrafficLightColor", new Object[] {TrafficLightColor.RED});
                }
                catch (SimRuntimeException exception)
                {
                    exception.printStackTrace();
                }
            }
        }
File Line
org\opentrafficsim\road\network\factory\opendrive\RoadTag.java 496
org\opentrafficsim\road\network\factory\opendrive\RoadTag.java 697
                    for (WidthTag widthTag : leftLane.widthTags)
                    {
                        Length relativeLength = widthTag.sOffst;
                        double factor = relativeLength.divideBy(lengthofLane).doubleValue();

                        if (factor < 0.98)
                        {
                            Length width = widthTag.a.plus(widthTag.b.multiplyBy(relativeLength.doubleValue()))
                                    .plus(widthTag.c.multiplyBy(Math.pow(relativeLength.doubleValue(), 2)))
                                    .plus(widthTag.d.multiplyBy(Math.pow(relativeLength.doubleValue(), 3)));

                            Length offSet = lastLane.getLateralCenterPosition(factor)
                                    .plus(lastLane.getWidth(factor).multiplyBy(0.5)).plus(width.multiplyBy(0.5));
File Line
org\opentrafficsim\road\network\factory\opendrive\RoadTag.java 508
org\opentrafficsim\road\network\factory\opendrive\RoadTag.java 709
                                    .plus(lastLane.getWidth(factor).multiplyBy(0.5)).plus(width.multiplyBy(0.5));

                            relativeLength = currentLink.getLength().multiplyBy(factor);

                            CrossSectionSlice slice = new CrossSectionSlice(relativeLength, offSet, width);
                            crossSectionSlices.add(slice);
                        }
                        else
                        {
                            CrossSectionSlice lastSlice = crossSectionSlices.get(crossSectionSlices.size() - 1);
                            Length width = lastSlice.getWidth();
                            Length offSet = lastSlice.getDesignLineOffset();
                            relativeLength = currentLink.getLength();

                            CrossSectionSlice slice = new CrossSectionSlice(relativeLength, offSet, width);
                            crossSectionSlices.add(slice);
                            break;
                        }
                    }
                }

                Speed speed = null;
                if (leftLane.speedTags.size() > 0)