Package org.openstreetmap.josm.data.osm

Examples of org.openstreetmap.josm.data.osm.RelationMember


        parent1.put("name", "name_parent1");
        Relation parent2 = ds.addRelation(2);
        parent2.put("type", "parent2");
        parent2.put("name", "name_parent2");
        Node child = ds.addNode(1);
        parent1.addMember(new RelationMember("", child));
        parent2.addMember(new RelationMember("", child));

        StringBuilder sb = new StringBuilder();
        TemplateEntry entry = parser.parse();
        entry.appendText(sb, child);
View Full Code Here


        Relation parent2 = ds.addRelation(2);
        parent2.put("type", "parent2");
        parent2.put("name", "name_parent2");
        Node child1 = ds.addNode(1);
        child1.put("type", "type1");
        parent1.addMember(new RelationMember("", child1));
        parent2.addMember(new RelationMember("", child1));
        Node child2 = ds.addNode(2);
        child2.put("type", "type2");
        parent1.addMember(new RelationMember("", child2));
        parent2.addMember(new RelationMember("", child2));


        StringBuilder sb = new StringBuilder();
        TemplateEntry entry = parser.parse();
        entry.appendText(sb, child1);
View Full Code Here

        Relation parent2 = ds.addRelation(2);
        parent2.put("type", "parent2");
        parent2.put("name", "name_parent2");
        Node child1 = ds.addNode(1);
        child1.put("type", "type1");
        parent1.addMember(new RelationMember("", child1));
        parent2.addMember(new RelationMember("", child1));
        Node child2 = ds.addNode(2);
        child2.put("type", "type2");
        parent1.addMember(new RelationMember("", child2));
        parent2.addMember(new RelationMember("", child2));
        Relation grandParent = ds.addRelation(3);
        grandParent.put("type", "grandparent");
        grandParent.put("name", "grandparent_name");
        grandParent.addMember(new RelationMember("", parent1));


        StringBuilder sb = new StringBuilder();
        TemplateEntry entry = parser.parse();
        entry.appendText(sb, child1);
View Full Code Here

        Relation parent2 = ds.addRelation(2);
        parent2.put("type", "type2");
        Node child1 = ds.addNode(1);
        child1.put("type", "child1");
        child1.put("name", "child1");
        parent1.addMember(new RelationMember("", child1));
        parent2.addMember(new RelationMember("", child1));
        Node child2 = ds.addNode(2);
        child2.put("type", "child2");
        child2.put("name", "child2");
        parent1.addMember(new RelationMember("", child2));
        parent2.addMember(new RelationMember("", child2));


        StringBuilder sb = new StringBuilder();
        TemplateEntry entry = parser.parse();
        entry.appendText(sb, parent2);
View Full Code Here

            int numNodesInRelation = (int)Math.round(Math.random() * 10);
            int start = (int)Math.round(Math.random() * numNodes);
            for (int j = 0; j < numNodesInRelation;j++) {
                int idx = (start + j) % 500;
                Node n = nodes.get(idx);
                r.addMember(new RelationMember("role-" + j, n));
            }
            int numWaysInRelation = (int)Math.round(Math.random() * 10);
            start = (int)Math.round(Math.random() * numWays);
            for (int j = 0; j < numWaysInRelation;j++) {
                int idx = (start + j) % 500;
                Way w = ways.get(idx);
                r.addMember(new RelationMember("role-" + j, w));
            }
            ds.addPrimitive(r);
        }

        return ds;
View Full Code Here

    protected static void populateTestDataSetWithRelations(DataSet ds) {
        for (int i=0;i<10;i++) {
            Relation r = new Relation();
            r.put("name", "relation-" +i);
            for (int j =0; j < 10; j++) {
                RelationMember member = new RelationMember("node-" + j, lookupNode(ds, i + j));
                r.addMember(member);
            }
            for (int j =0; j < 5; j++) {
                RelationMember member = new RelationMember("way-" + j, lookupWay(ds, i + j));
                r.addMember(member);
            }
            if (i > 5) {
                for (int j =0; j < 3; j++) {
                    RelationMember member = new RelationMember("relation-" + j, lookupRelation(ds, j));
                    logger.info(MessageFormat.format("adding relation {0} to relation {1}", j, i));
                    r.addMember(member);
                }
            }
            ds.addPrimitive(r);
View Full Code Here

    public void testOneRelationExistingMembersSelected() {
        DataSet source = new DataSet();
        Relation r1 = new Relation(1, 1);
        Node n20 = new Node(20, 1);
        n20.setCoor(new LatLon(0, 0));
        r1.addMember(new RelationMember("node-20",n20));
        Way w30 = new Way(30, 1);
        Node n21  = new Node(21);
        w30.addNode(n21);
        Node n22 = new Node(22);
        w30.addNode(n22);
        r1.addMember(new RelationMember("way-30",w30));
        Relation r40 = new Relation(40);
        r1.addMember(new RelationMember("relation-40", r40));
        source.addPrimitive(n20);
        source.addPrimitive(n21);
        source.addPrimitive(n22);
        source.addPrimitive(w30);
        source.addPrimitive(r40);
        source.addPrimitive(r1);
        source.setSelected(r1,n20,w30,r40);

        MergeSourceBuildingVisitor builder = new MergeSourceBuildingVisitor(source);
        DataSet hull = builder.build();
        assertNotNull(hull);
        assertEquals(1, hull.getWays().size());
        assertEquals(3, hull.getNodes().size());
        assertEquals(2, hull.getRelations().size());

        OsmPrimitive p = hull.getPrimitiveById(1, OsmPrimitiveType.RELATION);
        assertNotNull(p);
        assertEquals(p.getClass(), Relation.class);

        Way w = (Way)hull.getPrimitiveById(30,OsmPrimitiveType.WAY);
        assertNotNull(w);
        assertEquals(2, w.getNodesCount());
        Node n = (Node)hull.getPrimitiveById(21, OsmPrimitiveType.NODE);
        assertNotNull(n);
        assertTrue(w.containsNode(n));

        n = (Node)hull.getPrimitiveById(22,OsmPrimitiveType.NODE);
        assertNotNull(n);
        assertTrue(w.containsNode(n));

        Relation r = (Relation)hull.getPrimitiveById(40,OsmPrimitiveType.RELATION);
        assertNotNull(r);

        r = (Relation)hull.getPrimitiveById(1, OsmPrimitiveType.RELATION);
        assertNotNull(r);
        assertEquals(3, r.getMembersCount());
        RelationMember m = new RelationMember("node-20", hull.getPrimitiveById(20,OsmPrimitiveType.NODE));
        assertTrue(r.getMembers().contains(m));
        m = new RelationMember("way-30", hull.getPrimitiveById(30, OsmPrimitiveType.WAY));
        assertTrue(r.getMembers().contains(m));
        m = new RelationMember("relation-40", hull.getPrimitiveById(40, OsmPrimitiveType.RELATION));
        assertTrue(r.getMembers().contains(m));
    }
View Full Code Here

    @Test
    public void testOneRelationExistingMembersNotSelected() {
        DataSet source = new DataSet();
        Relation r1 = new Relation(1, 1);
        Node n20 = new Node(20);
        r1.addMember(new RelationMember("node-20",n20));
        Way w30 = new Way(30, 1);
        Node n21;
        w30.addNode(n21 = new Node(21));
        Node n22;
        w30.addNode(n22 = new Node(22));
        r1.addMember(new RelationMember("way-30",w30));
        Relation r40 = new Relation(40);
        r1.addMember(new RelationMember("relation-40", r40));
        source.addPrimitive(n20);
        source.addPrimitive(n21);
        source.addPrimitive(n22);
        source.addPrimitive(w30);
        source.addPrimitive(r40);
        source.addPrimitive(r1);
        source.setSelected(r1);

        MergeSourceBuildingVisitor builder = new MergeSourceBuildingVisitor(source);
        DataSet hull = builder.build();
        assertNotNull(hull);
        assertEquals(1, hull.getWays().size());
        assertEquals(1, hull.getNodes().size());
        assertEquals(2, hull.getRelations().size());

        OsmPrimitive p = hull.getPrimitiveById(1, OsmPrimitiveType.RELATION);
        assertNotNull(p);
        assertEquals(p.getClass(), Relation.class);

        Way w = (Way)hull.getPrimitiveById(30, OsmPrimitiveType.WAY);
        assertNotNull(w);
        assertTrue(w.isIncomplete());


        Node n = (Node)hull.getPrimitiveById(21,OsmPrimitiveType.NODE);
        assertNull(n);

        n = (Node)hull.getPrimitiveById(22, OsmPrimitiveType.NODE);
        assertNull(n);

        Relation r = (Relation)hull.getPrimitiveById(40, OsmPrimitiveType.RELATION);
        assertNotNull(r);
        assertTrue(r.isIncomplete());

        r = (Relation)hull.getPrimitiveById(1, OsmPrimitiveType.RELATION);
        assertNotNull(r);
        assertEquals(3, r.getMembersCount());
        RelationMember m = new RelationMember("node-20", hull.getPrimitiveById(20, OsmPrimitiveType.NODE));
        assertTrue(r.getMembers().contains(m));
        m = new RelationMember("way-30", hull.getPrimitiveById(30, OsmPrimitiveType.WAY));
        assertTrue(r.getMembers().contains(m));
        m = new RelationMember("relation-40", hull.getPrimitiveById(40, OsmPrimitiveType.RELATION));
        assertTrue(r.getMembers().contains(m));
    }
View Full Code Here

        DataSet source = new DataSet();
        Relation r1 = new Relation();
        r1.put("name", "r1");
        Node n20 = new Node(new LatLon(20.0,20.0));
        n20.put("name", "n20");
        r1.addMember(new RelationMember("node-20",n20));

        Way w30 = new Way();
        w30.put("name", "w30");
        Node n21;
        w30.addNode(n21 = new Node(new LatLon(21.0,21.0)));
        n21.put("name","n21");
        Node n22;
        w30.addNode(n22 = new Node(new LatLon(22.0,22.0)));
        n22.put("name","n22");
        r1.addMember(new RelationMember("way-30",w30));
        Relation r40 = new Relation();
        r40.put("name", "r40");
        r1.addMember(new RelationMember("relation-40", r40));

        source.addPrimitive(n20);
        source.addPrimitive(n21);
        source.addPrimitive(n22);
        source.addPrimitive(w30);
        source.addPrimitive(r40);
        source.addPrimitive(r1);
        source.setSelected(r1);

        MergeSourceBuildingVisitor builder = new MergeSourceBuildingVisitor(source);
        DataSet hull = builder.build();
        assertNotNull(hull);
        assertEquals(1, hull.getWays().size());
        assertEquals(3, hull.getNodes().size());
        assertEquals(2, hull.getRelations().size());

        OsmPrimitive p = lookupByName(hull.getRelations(), "r1");
        assertNotNull(p);
        assertEquals(p.getClass(), Relation.class);

        Way w = (Way)lookupByName(hull.getWays(), "w30");
        assertNotNull(w);
        assertEquals(2, w.getNodesCount());

        Node n = (Node)lookupByName(hull.getNodes(), "n21");
        assertNotNull(n);
        assertTrue(w.containsNode(n));

        n = (Node)lookupByName(hull.getNodes(), "n22");
        assertNotNull(n);
        assertTrue(w.containsNode(n));

        Relation r = (Relation)lookupByName(hull.getRelations(), "r40");
        assertNotNull(r);

        r = (Relation)lookupByName(hull.getRelations(), "r1");
        assertNotNull(r);
        assertEquals(3, r.getMembersCount());
        RelationMember m = new RelationMember("node-20", lookupByName(hull.getNodes(), "n20"));
        assertTrue(r.getMembers().contains(m));
        m = new RelationMember("way-30", lookupByName(hull.getWays(), "w30"));
        assertTrue(r.getMembers().contains(m));
        m = new RelationMember("relation-40", lookupByName(hull.getRelations(), "r40"));
        assertTrue(r.getMembers().contains(m));
    }
View Full Code Here

    @Test
    public void testOneRelationExistingRecursive() {
        DataSet source = new DataSet();
        Relation r1 = new Relation(1, 1);
        r1.addMember(new RelationMember("relation-1",r1));
        source.addPrimitive(r1);
        source.setSelected(r1);

        MergeSourceBuildingVisitor builder = new MergeSourceBuildingVisitor(source);
        DataSet hull = builder.build();
        assertNotNull(hull);
        assertEquals(1, hull.getRelations().size());

        Relation r = (Relation)hull.getPrimitiveById(1, OsmPrimitiveType.RELATION);
        assertNotNull(r);
        assertEquals(1, r.getMembersCount());
        assertTrue(r.getMembers().contains(new RelationMember("relation-1",r)));
    }
View Full Code Here

TOP

Related Classes of org.openstreetmap.josm.data.osm.RelationMember

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.