• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java RelationMember类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.openstreetmap.josm.data.osm.RelationMember的典型用法代码示例。如果您正苦于以下问题:Java RelationMember类的具体用法?Java RelationMember怎么用?Java RelationMember使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

RelationMember类属于org.openstreetmap.josm.data.osm包,在下文中一共展示了RelationMember类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createStopAreaRelation

点赞 3

import org.openstreetmap.josm.data.osm.RelationMember; //导入依赖的package包/类
/**
    * Forming commands for josm for saving stop area relation attributes
    * @param commands Original command list
 * @param stopArea Stop area object
    * @return Resulting command list
    */
private List<Command> createStopAreaRelation(List<Command> commands, StopArea stopArea) 
{
   	if(commands == null)
   		commands = new ArrayList<Command>();

   	Relation newRelation = new Relation();
	for(Node node : stopArea.stopPoints)
	{
		newRelation.addMember(new RelationMember(OSMTags.STOP_ROLE, node));
	}
	for(OsmPrimitive platform : stopArea.platforms)
	{
		newRelation.addMember(new RelationMember(OSMTags.PLATFORM_ROLE, platform));
	}
	for(OsmPrimitive otherMember : stopArea.otherMembers)
	{
		newRelation.addMember(new RelationMember("", otherMember));
	}
	Main.main.undoRedo.add(new AddCommand(newRelation));
	commands = generalTagAssign(newRelation, commands, stopArea);
	commands = assignTag(commands, newRelation, OSMTags.TYPE_TAG, OSMTags.PUBLIC_TRANSPORT_TAG);
	commands = assignTag(commands, newRelation, OSMTags.PUBLIC_TRANSPORT_TAG, OSMTags.STOP_AREA_TAG_VALUE);
   	return commands;
}
 

开发者ID:bwr57,
项目名称:CustomizePublicTransportStop,
代码行数:31,
代码来源:CustomizeStopAreaOperation.java

示例2: addNewRelationMember

点赞 3

import org.openstreetmap.josm.data.osm.RelationMember; //导入依赖的package包/类
/**
 * Adding of new stop area members to relation
 * @param commands Original command list
 * @param targetRelation Stop area relation
 * @param member Stop area relation member
 * @param roleName Role name
 * @return Resulting command list
 */
public static List<Command> addNewRelationMember(List<Command> commands, Relation targetRelation, OsmPrimitive member, String roleName)
{
   	if(commands == null)
   		commands = new ArrayList<Command>();

   	for(RelationMember relationMember : targetRelation.getMembers())
	{
		if(relationMember.getMember() == member)
		{
			if(relationMember.getRole() == roleName)
			{
				return commands;
			}
			return commands;
		}
	}
	targetRelation.addMember(new RelationMember(roleName, member));
	commands.add(new ChangeCommand(targetRelation, targetRelation));
	return commands;	
}
 

开发者ID:bwr57,
项目名称:CustomizePublicTransportStop,
代码行数:29,
代码来源:CustomizeStopAreaOperation.java

示例3: extractRelation

点赞 3

import org.openstreetmap.josm.data.osm.RelationMember; //导入依赖的package包/类
private void extractRelation(Relation rel) {
	List <RelationMember> members = rel.getMembers();
	for(RelationMember x : members) {
		if(x.getRole().equals("forward") || x.getRole().equals("backward") || x.getRole().equals(""))
			if(x.getType()==OsmPrimitiveType.WAY) {
				Way w = x.getWay();
				List <Node> y = w.getNodes();
				for(int i=0; i<y.size()-1; i++) {
					Node a = y.get(i);
					Node b = y.get(i+1);
					Pair <Node, Node> tmp2 = new Pair<>(a,b);
					pairsRelations.add(tmp2);
				}
			}
	}
}
 

开发者ID:ztmtoosm,
项目名称:easy-routes,
代码行数:17,
代码来源:DiffLayer.java

示例4: putRelationWays

点赞 3

import org.openstreetmap.josm.data.osm.RelationMember; //导入依赖的package包/类
public void putRelationWays(Relation x) {
	if(lay==null)
		return;
	List<Way> toAdd;
	List<String> forBack = new ArrayList<>();
	try {
		toAdd = lay.splitWays(forBack);
	int i=0;
	for(Way y : toAdd) {
		String foo = "";
		if(forBack!=null && forBack.size()>i && forBack.get(i)!=null)
			foo=forBack.get(i);
		RelationMember member = new RelationMember(foo, y);
		x.addMember(member);
		i++;
	}
	}catch (NodeConnectException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 

开发者ID:ztmtoosm,
项目名称:easy-routes,
代码行数:22,
代码来源:SingleRelationBuilder.java

示例5: putMeMaster

点赞 3

import org.openstreetmap.josm.data.osm.RelationMember; //导入依赖的package包/类
void putMeMaster(Relation x, RelationsBuilder bui) {
	for(int i=0; i<parentRel.size(); i++) {
		Relation xyz=bui.relationMap.get(parentRel.get(i));
		if(xyz!=null) {
			List<RelationMember> lista=xyz.getMembers();
			boolean czyDodawać = true;
			for(RelationMember foo : lista) {
				if(foo.getMember()==x) {
					czyDodawać = false;
				}
			}
			if(czyDodawać) {
				RelationMember member = new RelationMember("", x);
				xyz.addMember(member);
				xyz.setModified(true);
			}
		}
	}
}
 

开发者ID:ztmtoosm,
项目名称:easy-routes,
代码行数:20,
代码来源:SingleRelationBuilder.java

示例6: addToGraph

点赞 2

import org.openstreetmap.josm.data.osm.RelationMember; //导入依赖的package包/类
public void addToGraph(Node n, Relation g) {
    if(!g.getMemberPrimitives().contains(n)) {
        Main.debug("> Add node to relation");
        g.addMember(new RelationMember(Constants.OSM_RELATION_ROLE_STATE, n));
        // WORKAROUND2: Add to the graph the ways linked to the node
        for(OsmPrimitive p : n.getReferrers(false)) {
            if(p instanceof Way) {
                Main.debug("> I found a related way");
                addToGraph((Way)p, g);
            }
        }
    }
}
 

开发者ID:STEMLab,
项目名称:JOSM-IndoorEditor,
代码行数:14,
代码来源:FloorsFilterDialog.java

示例7: updateAssociatedStreetRelation

点赞 2

import org.openstreetmap.josm.data.osm.RelationMember; //导入依赖的package包/类
private void updateAssociatedStreetRelation(Relation associatedStreet, List<Node> housenumbers, Collection<Way> ways) {
    Relation newAssociatedStreet = new Relation(associatedStreet);
    // remove housenumbers as they have been deleted
    newAssociatedStreet.removeMembersFor(housenumbers);
    for (Way w : ways) {
        newAssociatedStreet.addMember(new RelationMember("house", w));
    }
    /*if (!keepOutline) {
        newAssociatedStreet.removeMembersFor(outline);
    }*/
    this.commands.add(new ChangeCommand(associatedStreet, newAssociatedStreet));
}
 

开发者ID:derickr,
项目名称:josm-plugin-uberterrace,
代码行数:13,
代码来源:TerracerAction.java

示例8: addNewAssociatedStreetRelation

点赞 2

import org.openstreetmap.josm.data.osm.RelationMember; //导入依赖的package包/类
private void addNewAssociatedStreetRelation(Way street, String streetName, Collection<Way> ways) {
    Relation associatedStreet = new Relation();
    associatedStreet.put("type", "associatedStreet");
    if (street != null) { // a street was part of the selection
        associatedStreet.put("name", street.get("name"));
        associatedStreet.addMember(new RelationMember("street", street));
    } else {
        associatedStreet.put("name", streetName);
    }
    for (Way w : ways) {
        associatedStreet.addMember(new RelationMember("house", w));
    }
    this.commands.add(new AddCommand(associatedStreet));
}
 

开发者ID:derickr,
项目名称:josm-plugin-uberterrace,
代码行数:15,
代码来源:TerracerAction.java

示例9: parsePesce

点赞 2

import org.openstreetmap.josm.data.osm.RelationMember; //导入依赖的package包/类
protected DataSet parsePesce(InputStream in, ProgressMonitor instance)
        throws IllegalDataException {
    
    // Test: print context
    Main.debug("i-locate upload context");
    Map<String,String> context = Context.getInstance().store; 
    for(String k : context.keySet()) {
        Main.debug(String.format("%s -> %s",k,context.get(k)));
    }
    
    DataSet data = new DataSet();
    
    data.setUploadDiscouraged(true);
    
    data.beginUpdate();
    for(String line : convertStreamToString(in).split("\n")) {
        String[] s = line.split(",");
        if(s.length<2) {
            continue;
        }
        double lat = Double.parseDouble(s[0]);
        double lon = Double.parseDouble(s[1]);
        double scale = s.length>2 ? Double.parseDouble(s[2]) : 5.;

        Map<String, String> keys;
        Relation polygon = new Relation();
        keys = new HashMap<>();
        keys.put("type", "multipolygon");
        polygon.setKeys(keys);
        for(int j=0 ; j<2; j++){
            Node first = null;
            Way fishWay = new Way();
            for(int i=0 ; i<Constants.DELTA[j].length ; i++) {
                Node n = new Node(new LatLon(lat + scale * Constants.DELTA[j][i][0],lon + scale * Constants.DELTA[j][i][1]));
                keys = n.getKeys();
                if(null==keys){
                    keys = new HashMap<>();
                }
                if(Constants.DELTA[j][i].length > 2) {
                    if(Constants.DELTA[j][i][2] == 1.) {
                        keys.put("name", "testa");
                    } else if(Constants.DELTA[j][i][2] == 2.) {
                        keys.put("name", "coda");
                    }
                }
                if(null == first) {
                    first = n;
                }
                n.setKeys(keys);
    
                data.addPrimitive(n);
                fishWay.addNode(n);
            }
            fishWay.addNode(first);
            data.addPrimitive(fishWay);
            polygon.addMember(new RelationMember(j == 0 ? "outer" : "inner", fishWay));
        }
        data.addPrimitive(polygon);    
    }
    
    data.endUpdate();
    return data;
}
 

开发者ID:STEMLab,
项目名称:JOSM-IndoorEditor,
代码行数:64,
代码来源:PesceImporter.java

示例10: edges

点赞 2

import org.openstreetmap.josm.data.osm.RelationMember; //导入依赖的package包/类
private EdgesType edges(Relation spaceLayerRelation)  {
    EdgesType edgesType = new EdgesType();
    LineStringType tmpTransitionLine;// PLACEHOLDER
    edgesType.setId(idsFactory.newId("Edges"));

    
    for(RelationMember member : spaceLayerRelation.getMembers()) {
        if(member.getRole().equals(Constants.OSM_RELATION_ROLE_TRANSITION)) {
            Way w = member.getWay();
            
            Node start = null;
            for(Node end : w.getNodes()) {
                if(null==start) {
                    start = end;
                    continue;
                }
                
                List<String> linkedStates = new ArrayList<>();
                linkedStates.add(start.get(Constants.OSM_KEY_ID));
                linkedStates.add(end.get(Constants.OSM_KEY_ID));
                tmpTransitionLine = newLineStringProperty(_gmlObjectFactory, idsFactory.newId("nLS"), Constants.SRID4326, 
                        new double[] { start.getCoor().getX(), end.getCoor().getX() }, 
                        new double[] { start.getCoor().getY(), end.getCoor().getY() },
                        new double[] { 
                    Double.parseDouble(start.get(Constants.OSM_KEY_LEVEL)),
                    Double.parseDouble(end.get(Constants.OSM_KEY_LEVEL)) });
                String id = w.get(Constants.OSM_KEY_ID)!=null ? w.get(Constants.OSM_KEY_ID) : idsFactory.newId("nT");
                // If 1 way is mapped to more transition I need mode ids from a name
                if(w.get(Constants.OSM_KEY_ID)!=null && w.getNodes().size() > 2) {
                    id = idsFactory.newId(id);
                }
                edgesType.getTransitionMember().add(newTransitionMember(_gmlObjectFactory, 
                        id, 
                        1d, tmpTransitionLine, linkedStates));

                // Add references of the transaction to the involved States
                for(Node state : new Node[] {start, end}) {
                    
                    TransitionPropertyType transitionLink = new TransitionPropertyType();
                    transitionLink.setHref(newReferenceString(id));
                    stateTransitionsReferences.get(state.get(Constants.OSM_KEY_ID)).add(transitionLink);
                }
                
                start = end;
                
            }
        }
    }
    
    return edgesType;
}
 

开发者ID:STEMLab,
项目名称:JOSM-IndoorEditor,
代码行数:52,
代码来源:OSMConverter.java

示例11: nodes

点赞 2

import org.openstreetmap.josm.data.osm.RelationMember; //导入依赖的package包/类
public void nodes(List<NodesType> nodesType, Relation spaceLayerRelation) {
    nodes = new HashMap<>();
    
    for(NodesType type : nodesType) {
        System.out.println("NodesType id: "+type.getId());
        
        for(StateMemberType node : type.getStateMember()) {
            StateType state = node.getState();
            System.out.println("State id: "+state.getId()); // used into Edges to identify states
            
            //Get State Name
            String stateName = null;
            
            List<CodeType> names = state.getName();
            if(names.size() > 1) {
                stateName = names.get(0).getValue();
            }
            
            if(stateName == null) {
                StringOrRefType des = state.getDescription();
                if(des != null) stateName = des.getTitle();
            }
            
            boolean isAnchorNode = state.isIsAnchorNode();
            boolean isDoor = state.isIsDoor();
            // I don't read description
            
            // I'm assuming a lot of wrong things
            List<Double> position = state.getGeometry().getPoint().getPos().getValue();
            System.out.println(String.format(Locale.US, "%s %f %f", state.getId(), position.get(0), position.get(1)));
            if(test) {
                nodes.put(state.getId(), null);
            } else {
                // Node type can be used only inside JOSM
                Node josmNode = new Node(new LatLon(position.get(0), position.get(1)));
                josmNode.put(Constants.OSM_KEY_ID, state.getId());
                josmNode.put(Constants.OSM_KEY_LEVEL, String.valueOf(position.get(2).intValue()));
                josmNode.put(Constants.OSM_KEY_ANCHORNODE, isAnchorNode ? Constants.OSM_VALUES_TRUE[0] : Constants.OSM_VALUE_FALSE);
                josmNode.put(Constants.OSM_KEY_DOOR, isDoor ? Constants.OSM_VALUES_TRUE[0] : Constants.OSM_VALUE_FALSE);
                nodes.put(state.getId(), josmNode);
                data.addPrimitive(josmNode);
                spaceLayerRelation.addMember(new RelationMember(Constants.OSM_RELATION_ROLE_STATE, josmNode));
            }
        }
    }
    
    
}
 

开发者ID:STEMLab,
项目名称:JOSM-IndoorEditor,
代码行数:49,
代码来源:IGMLConverter.java

示例12: fromSelectedObject

点赞 2

import org.openstreetmap.josm.data.osm.RelationMember; //导入依赖的package包/类
/**
 * Setting of stop area from selected josm object
 * @param selectedObject Selected josm object
 */
public void fromSelectedObject(StopArea stopArea)
{
	Collection<OsmPrimitive> selectedObjects = new ArrayList<OsmPrimitive>();
	selectedObjects.add(stopArea.selectedObject);
	for(Relation rel : OsmPrimitive.getParentRelations(selectedObjects))
	{
		if(compareTag(rel, OSMTags.TYPE_TAG, OSMTags.PUBLIC_TRANSPORT_TAG) && compareTag(rel, OSMTags.PUBLIC_TRANSPORT_TAG, OSMTags.STOP_AREA_TAG_VALUE))
		{
			stopArea.stopAreaRelation = rel;
		}
		if(stopArea.stopAreaRelation != null)
			break;
	}
	
	if(stopArea.stopAreaRelation != null)
	{
		parseTags(stopArea, stopArea.stopAreaRelation);
		parseTags(stopArea, stopArea.selectedObject);
		for(RelationMember member : stopArea.stopAreaRelation.getMembers())
		{				
			if(member.getMember() instanceof Node && compareTag(member.getMember(), OSMTags.PUBLIC_TRANSPORT_TAG, OSMTags.STOP_POSITION_TAG_VALUE))
			{
				stopArea.isStopPointExists = true;
				stopArea.stopPoints.add(member.getNode());
			}
			else
				if(compareTag(member.getMember(), OSMTags.PUBLIC_TRANSPORT_TAG, OSMTags.PLATFORM_TAG_VALUE))
				{
					stopArea.platforms.add(member.getMember());
				}
				else
				{
					stopArea.otherMembers.add(member.getMember());
				}
			parseTags(stopArea, member.getMember());
		}
		if(!stopArea.platforms.contains(stopArea.selectedObject))
		{
			parseTags(stopArea, stopArea.selectedObject);
			stopArea.platforms.add(stopArea.selectedObject);
		}
	}
	else
	{
		parseTags(stopArea, stopArea.selectedObject);
		stopArea.platforms.add(stopArea.selectedObject);
	}
	for(OsmPrimitive platform : stopArea.platforms)
	{
		if(testIsTransportTypeAssigned(platform))
		{
			stopArea.isAssignTransportType = true;
			break;
		}
	}
	if(!(stopArea.isBus || stopArea.isTrolleybus || stopArea.isShareTaxi) && stopArea.selectedObject != null && (compareTag(stopArea.selectedObject, OSMTags.HIGHWAY_TAG, OSMTags.BUS_STOP_TAG_VALUE) || stopArea.isBusStation))
	{
		stopArea.isBus = true;
	}		
}
 

开发者ID:bwr57,
项目名称:CustomizePublicTransportStop,
代码行数:65,
代码来源:CreateStopAreaFromSelectedObjectOperation.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)