• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java OsmPrimitive类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



OsmPrimitive类属于org.openstreetmap.josm.data.osm包,在下文中一共展示了OsmPrimitive类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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++;
        }
    }
}
 
开发者ID:JOSM,项目名称:geojson,代码行数:21,代码来源:GeoJsonDialog.java


示例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);
}
 
开发者ID:JOSM,项目名称:geojson,代码行数:20,代码来源:DataSetBuilder.java


示例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;
}
 
开发者ID:bwr57,项目名称:CustomizePublicTransportStop,代码行数:31,代码来源:CustomizeStopAreaOperation.java


示例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;	
}
 
开发者ID:bwr57,项目名称:CustomizePublicTransportStop,代码行数:29,代码来源:CustomizeStopAreaOperation.java


示例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;
}
 
开发者ID:bwr57,项目名称:CustomizePublicTransportStop,代码行数:26,代码来源:CustomizeStopAreaOperation.java


示例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;
}
 
开发者ID:bwr57,项目名称:CustomizePublicTransportStop,代码行数:30,代码来源:CustomizeStopAreaOperation.java


示例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;
}
 
开发者ID:bwr57,项目名称:CustomizePublicTransportStop,代码行数:31,代码来源:CustomizeStopAreaOperation.java


示例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;
}
 
开发者ID:bwr57,项目名称:CustomizePublicTransportStop,代码行数:34,代码来源:CustomizeStopAreaOperation.java


示例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;
  }
 
开发者ID:bwr57,项目名称:CustomizePublicTransportStop,代码行数:25,代码来源:StopAreaOperationBase.java


示例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();
}
 
开发者ID:kolesar-andras,项目名称:josm-plugin-improve-way,代码行数:25,代码来源:ImproveWayAccuracyAction.java


示例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();
}
 
开发者ID:ztmtoosm,项目名称:easy-routes,代码行数:17,代码来源:RoutingSpecial.java


示例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();
}
 
开发者ID:ztmtoosm,项目名称:easy-routes,代码行数:17,代码来源:RoutingSpecial.java


示例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);
  }
 
开发者ID:ztmtoosm,项目名称:easy-routes,代码行数:19,代码来源:LayNodesAction.java


示例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();
	}
}
 
开发者ID:ztmtoosm,项目名称:easy-routes,代码行数:21,代码来源:ConnectNodesAction.java


示例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);
            }
        }
    }
}
 
开发者ID:STEMLab,项目名称:JOSM-IndoorEditor,代码行数:14,代码来源:FloorsFilterDialog.java


示例16: zoomTo

import org.openstreetmap.josm.data.osm.OsmPrimitive; //导入依赖的package包/类
/**
 * Focus the map on a specific OSM primitive
 *
 * @param primitive
 *            The primitive to zoom to
 */
private void zoomTo(final OsmPrimitive primitive) {
    if (primitive == null) {
        return;
    }
    if (primitive instanceof Node) {
        MainApplication.getMap().mapView.zoomTo(((Node) primitive).getCoor());
        return;
    }
    final BoundingXYVisitor v = new BoundingXYVisitor();
    v.visit((Way) primitive);
    MainApplication.getMap().mapView.zoomTo(v.getBounds());
}
 
开发者ID:JOSM,项目名称:geojson,代码行数:19,代码来源:GeoJsonDialog.java


示例17: testIsTransportTypeAssigned

import org.openstreetmap.josm.data.osm.OsmPrimitive; //导入依赖的package包/类
/**
 * Test, are transport types assigned to platforms
 * @param platform Platform object
 * @return true, if transport types assigned to this platforms
 */
public boolean testIsTransportTypeAssigned(OsmPrimitive platform)
{
	String[] transportTypes = new String[] { OSMTags.BUS_TAG, OSMTags.TROLLEYBUS_TAG, OSMTags.SHARE_TAXI_TAG, OSMTags.TRAM_TAG, OSMTags.TRAIN_TAG };
	for(String transportType : transportTypes)
	{
		if(compareTag(platform, transportType, OSMTags.YES_TAG_VALUE))
			return true;			
	}
	return false;
}
 
开发者ID:bwr57,项目名称:CustomizePublicTransportStop,代码行数:16,代码来源:CreateStopAreaFromSelectedObjectOperation.java


示例18: performCustomizing

import org.openstreetmap.josm.data.osm.OsmPrimitive; //导入依赖的package包/类
/**
 * Construct stop area object from selected JOSM object
 * @param stopArea Original stop area object
 * @return Stop area objects with settings of selected JOSM object and included it stop area relation
 */
@Override
public StopArea performCustomizing(StopArea stopArea) 
{
	if(getCurrentDataSet() == null)
		return null;
	OsmPrimitive selectedObject = getCurrentDataSet().getSelectedNodesAndWays().iterator().next();
	if(selectedObject == null)
		return null;
	if(stopArea == null)
		stopArea = new StopArea(selectedObject);
	fromSelectedObject(stopArea);
	return stopArea;
}
 
开发者ID:bwr57,项目名称:CustomizePublicTransportStop,代码行数:19,代码来源:CreateStopAreaFromSelectedObjectOperation.java


示例19: nameTagAssign

import org.openstreetmap.josm.data.osm.OsmPrimitive; //导入依赖的package包/类
/**
* Forming commands for josm for saving name and name:en attributes stop of area members and relation attributes
* @param target Stop area member or relation
* @param commands List of commands
* @param stopArea Stop area object
* @return Resulting list of commands
*/
  public List<Command> nameTagAssign(OsmPrimitive target, List<Command> commands, StopArea stopArea)
  {
  	if(commands == null)
  		commands = new ArrayList<Command>();
  	
  	commands = assignTag(commands, target, OSMTags.NAME_TAG, "".equals(stopArea.name) ? null : stopArea.name);
  	commands = assignTag(commands, target, OSMTags.NAME_EN_TAG, "".equals(stopArea.nameEn) ? null : stopArea.nameEn);
  	return commands;
  }
 
开发者ID:bwr57,项目名称:CustomizePublicTransportStop,代码行数:17,代码来源:CustomizeStopAreaOperation.java


示例20: transportTypeTagClearing

import org.openstreetmap.josm.data.osm.OsmPrimitive; //导入依赖的package包/类
/**
    * Clear transport type tags
    * @param target Josm object for tag clearing 
    * @param commands Command list
    * @return Resulting list of commands
    */
protected List<Command> transportTypeTagClearing(OsmPrimitive target,
		List<Command> commands) {
	commands = clearTag(commands, target, OSMTags.BUS_TAG);
	commands = clearTag(commands, target, OSMTags.SHARE_TAXI_TAG);
	commands = clearTag(commands, target, OSMTags.TROLLEYBUS_TAG);
	commands = clearTag(commands, target, OSMTags.TRAM_TAG);
	commands = clearTag(commands, target, OSMTags.TRAIN_TAG);
	return commands;
}
 
开发者ID:bwr57,项目名称:CustomizePublicTransportStop,代码行数:16,代码来源:CustomizeStopAreaOperation.java



注:本文中的org.openstreetmap.josm.data.osm.OsmPrimitive类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SWTPaintCanvas类代码示例发布时间:2022-05-22
下一篇:
Java IServiceConnection类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap