本文整理汇总了Java中org.openstreetmap.josm.data.osm.OsmPrimitive类的典型用法代码示例。如果您正苦于以下问题:Java OsmPrimitive类的具体用法?Java OsmPrimitive怎么用?Java OsmPrimitive使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OsmPrimitive类属于org.openstreetmap.josm.data.osm包,在下文中一共展示了OsmPrimitive类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showDataFromLayer
import org.openstreetmap.josm.data.osm.OsmPrimitive; //导入依赖的package包/类
private void showDataFromLayer() {
listModel.clear();
indexToIdentifier.clear();
identifierToIndex.clear();
if (layer != null && layer.data != null && !layer.data.allPrimitives().isEmpty()) {
int index = 0;
// Build the maps and add the primitives to the list's model
for (final OsmPrimitive osmPrimitive : layer.data.allPrimitives()) {
if (osmPrimitive instanceof Node && osmPrimitive.getKeys().isEmpty()) { // skip points without tags
continue;
}
listModel.addElement(new PrintablePrimitive(index, osmPrimitive));
indexToIdentifier.put(index, osmPrimitive.getPrimitiveId());
identifierToIndex.put(osmPrimitive.getPrimitiveId(), index);
index++;
}
}
}
示例2: build
import org.openstreetmap.josm.data.osm.OsmPrimitive; //导入依赖的package包/类
public BoundedDataSet build(final GeoJsonObject data) {
dataSet = new DataSet();
if (data instanceof FeatureCollection) {
processFeatureCollection((FeatureCollection) data);
} else if (data instanceof GeometryCollection) {
processGeometryCollection(null, (GeometryCollection) data);
} else if (data instanceof Feature) {
processFeature((Feature) data);
} else {
processGeometry(null, data);
}
Bounds bounds = null;
for (OsmPrimitive osmPrimitive : dataSet.allPrimitives()) {
bounds = mergeBounds(bounds, osmPrimitive);
}
return new BoundedDataSet(dataSet, bounds);
}
示例3: createStopAreaRelation
import org.openstreetmap.josm.data.osm.OsmPrimitive; //导入依赖的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;
}
示例4: addNewRelationMember
import org.openstreetmap.josm.data.osm.OsmPrimitive; //导入依赖的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;
}
示例5: addNewRelationMembers
import org.openstreetmap.josm.data.osm.OsmPrimitive; //导入依赖的package包/类
/**
* Adding new stop area members to relation
* @param commands Original command list
* @param stopArea Stop area object
* @return Resulting command list
*/
private List<Command> addNewRelationMembers(List<Command> commands, StopArea stopArea)
{
if(commands == null)
commands = new ArrayList<Command>();
for(OsmPrimitive stopPoint : stopArea.stopPoints)
{
commands = addNewRelationMember(commands, stopArea.stopAreaRelation, stopPoint, OSMTags.STOP_ROLE);
}
for(OsmPrimitive platform : stopArea.platforms)
{
commands = addNewRelationMember(commands, stopArea.stopAreaRelation, platform, OSMTags.PLATFORM_ROLE);
}
for(OsmPrimitive otherMember : stopArea.otherMembers)
{
commands = addNewRelationMember(commands, stopArea.stopAreaRelation, otherMember, null);
}
return commands;
}
示例6: searchBusStop
import org.openstreetmap.josm.data.osm.OsmPrimitive; //导入依赖的package包/类
/**
* Testing, is josm object bus stop node or contains bus stop node, defined by tag and its value
* @param member Josm object
* @param tag Tag name
* @param tagValue Tag value
* @return true, if josm object is bus stop node or contains bus stop node
*/
private Node searchBusStop(OsmPrimitive member, String tag, String tagValue)
{
if(member instanceof Node)
{
if(compareTag(member, tag, tagValue))
{
return (Node)member;
}
}
else
{
Way memberWay = (Way) member;
for(Node node : memberWay.getNodes())
{
if(compareTag(node, tag, tagValue))
{
return node;
}
}
}
return null;
}
示例7: clearExcessTags
import org.openstreetmap.josm.data.osm.OsmPrimitive; //导入依赖的package包/类
/**
* Clear excess tags from JOSM object and its nodes
* @param commands Original command list
* @param target JOSM object
* @param tag Tag name
* @param tagValue Tag value
* @return Resulting command list
*/
private List<Command> clearExcessTags(List<Command> commands, OsmPrimitive target, String tag, String tagValue)
{
if(commands == null)
commands = new ArrayList<Command>();
if(compareTag(target, tag, tagValue))
{
commands = clearTag(commands, target, tag);
}
if(target instanceof Way)
{
Way memberWay = (Way) target;
for(Node node : memberWay.getNodes())
{
if(compareTag(node, tag, tagValue))
{
commands = clearTag(commands, target, tag);
}
}
}
return commands;
}
示例8: createSeparateBusStopNode
import org.openstreetmap.josm.data.osm.OsmPrimitive; //导入依赖的package包/类
/**
* Create separate bus stop node or assign bus stop tag to platform node
* @param commands Original command list
* @param stopArea Stop area object
* @param firstPlatform First platform in stop area relation
* @param tag Tag name
* @param tagValue Tag value
* @return Resulting command list
*/
protected List<Command> createSeparateBusStopNode(List<Command> commands, StopArea stopArea, OsmPrimitive firstPlatform, String tag, String tagValue)
{
if(commands == null)
commands = new ArrayList<Command>();
LatLon centerOfPlatform = getCenterOfWay(firstPlatform);
if(firstPlatform instanceof Way)
{
if(centerOfPlatform != null)
{
Node newNode =new Node();
newNode.setCoor(centerOfPlatform);
Main.main.undoRedo.add(new AddCommand(newNode));
Main.main.undoRedo.add(new ChangePropertyCommand(newNode, tag, tagValue));
commands = assignTag(commands, newNode, tag, tagValue);
stopArea.otherMembers.add(newNode);
}
}
else
{
commands = assignTag(commands, firstPlatform, tag, tagValue);
}
return commands;
}
示例9: getCenterOfWay
import org.openstreetmap.josm.data.osm.OsmPrimitive; //导入依赖的package包/类
/**
* Calculation of center of platform, if platform is way
* @param platform Platform primitive
* @return Coordinates of center of platform
*/
public static LatLon getCenterOfWay(OsmPrimitive platform)
{
if(platform instanceof Way)
{
//p = mapView.getPoint((Node) stopArea.selectedObject);
Double sumLat = 0.0;
Double sumLon = 0.0;
Integer countNode = 0;
for(Node node : ((Way) platform).getNodes())
{
LatLon coord = node.getCoor();
sumLat += coord.getX();
sumLon += coord.getY();
countNode++;
}
return new LatLon(sumLon / countNode, sumLat / countNode);
}
return null;
}
示例10: startImproving
import org.openstreetmap.josm.data.osm.OsmPrimitive; //导入依赖的package包/类
/**
* Switches to Improving state
*
* @param targetWay Way that is going to be improved
*/
public void startImproving(Way targetWay) {
state = State.improving;
Collection<OsmPrimitive> currentSelection = getCurrentDataSet().getSelected();
if (currentSelection.size() != 1
|| !currentSelection.iterator().next().equals(targetWay)) {
selectionChangedBlocked = true;
getCurrentDataSet().clearSelection();
getCurrentDataSet().setSelected(targetWay.getPrimitiveId());
selectionChangedBlocked = false;
}
this.targetWay = targetWay;
this.candidateNode = null;
this.candidateSegment = null;
mv.repaint();
updateStatusLine();
}
示例11: tagsChanged
import org.openstreetmap.josm.data.osm.OsmPrimitive; //导入依赖的package包/类
@Override
public void tagsChanged(TagsChangedEvent event) {
if(listeners.size()==0)
return;
List<? extends OsmPrimitive> foo = event.getPrimitives();
boolean ok =false;
for(OsmPrimitive x : foo) {
if(x.getDisplayType()!=OsmPrimitiveType.RELATION && x.getDisplayType()!=OsmPrimitiveType.MULTIPOLYGON)
ok = true;
}
if(!ok)
return;
System.out.println("TAGS CHANGED");
changeDelay();
}
示例12: otherDatasetChange
import org.openstreetmap.josm.data.osm.OsmPrimitive; //导入依赖的package包/类
@Override
public void otherDatasetChange(AbstractDatasetChangedEvent event) {
if(listeners.size()==0)
return;
Collection<? extends OsmPrimitive> foo = event.getPrimitives();
boolean ok =false;
for(OsmPrimitive x : foo) {
if(x.getDisplayType()!=OsmPrimitiveType.RELATION && x.getDisplayType()!=OsmPrimitiveType.MULTIPOLYGON)
ok = true;
}
if(!ok)
return;
System.out.println("OTHER");
changeDelay();
}
示例13: actionPerformed
import org.openstreetmap.josm.data.osm.OsmPrimitive; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
if (!isEnabled() || !Main.map.mapView.isActiveLayerVisible())
return;
Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
List<Node> selection2 = OsmPrimitive.getFilteredList(selection, Node.class);
if(selection2.size()<=1)
{
new Notification(
tr("Two or more nodes are necessary."))
.setIcon(JOptionPane.WARNING_MESSAGE)
.show();
}
RoutingLayer lay;
lay = new RoutingLayer(selection2, "xxx", new RoutingSpecial(Main.pref.getArray("easy-routes.weights")));
Main.main.addLayer(lay);
}
示例14: actionPerformed
import org.openstreetmap.josm.data.osm.OsmPrimitive; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
if (!isEnabled() || !Main.map.mapView.isActiveLayerVisible())
return;
Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
List<Node> selection2 = OsmPrimitive.getFilteredList(selection,
Node.class);
List<Way> selection3 = OsmPrimitive.getFilteredList(selection,
Way.class);
if (selection2.size() > 1) {
foo3(selection2);
} else if (selection3.size()==2) {
foo4(selection3);
} else {
new Notification(tr("Two or more nodes are necessary, or two ways.")).setIcon(
JOptionPane.WARNING_MESSAGE).show();
}
}
示例15: addToGraph
import org.openstreetmap.josm.data.osm.OsmPrimitive; //导入依赖的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);
}
}
}
}