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

Java Box类代码示例

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

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



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

示例1: fillRandomTree

import org.oscim.core.Box; //导入依赖的package包/类
ArrayList<Item> fillRandomTree(SpatialIndex<Item> q, int numItems) {
	Box box = new Box();
	ArrayList<Item> items = new ArrayList<Item>(numItems + 16);

	for (int i = 0; i < numItems; i++) {
		box.xmin = (int) (rand.nextDouble() * 10000 - 5000);
		box.ymin = (int) (rand.nextDouble() * 10000 - 5000);
		box.xmax = (int) (box.xmin + rand.nextDouble() * 500);
		box.ymax = (int) (box.ymin + rand.nextDouble() * 500);

		Item it = new Item(box, i);
		q.insert(box, it);

		items.add(it);

	}
	return items;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:19,代码来源:QuadTreeTest.java


示例2: shouldWork6

import org.oscim.core.Box; //导入依赖的package包/类
@Test
public void shouldWork6() {
	SpatialIndex<Item> q = new QuadTree<Item>(Short.MAX_VALUE + 1, 16);

	Box box = new Box(-4184.653317773969,
	                  3183.6174297948446,
	                  -4088.3197324911957,
	                  3222.7770427421046);

	Item it = new Item(box, 1);
	q.insert(box, it);

	q.search(it.bbox, new SearchCb<Item>() {
		@Override
		public boolean call(Item item, Object context) {
			out.println("==> " + item + " " + (context == item));
			return true;
		}
	}, it);
	Assert.assertEquals(1, q.size());
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:22,代码来源:QuadTreeTest.java


示例3: getViewBox

import org.oscim.core.Box; //导入依赖的package包/类
/**
 * Get the minimal axis-aligned BoundingBox that encloses
 * the visible part of the map. Sets box to map coordinates:
 * minX,minY,maxY,maxY
 */
public synchronized void getViewBox(Box box) {
	float[] coords = mViewCoords;
	getMapViewProjection(coords);

	box.minX = coords[0];
	box.maxX = coords[0];
	box.minY = coords[1];
	box.maxY = coords[1];

	for (int i = 2; i < 8; i += 2) {
		box.minX = Math.min(box.minX, coords[i]);
		box.maxX = Math.max(box.maxX, coords[i]);
		box.minY = Math.min(box.minY, coords[i + 1]);
		box.maxY = Math.max(box.maxY, coords[i + 1]);
	}

	box.minX = (mCurX + box.minX) / mCurScale;
	box.maxX = (mCurX + box.maxX) / mCurScale;
	box.minY = (mCurY + box.minY) / mCurScale;
	box.maxY = (mCurY + box.maxY) / mCurScale;
}
 
开发者ID:opensciencemap,项目名称:vtm-android,代码行数:27,代码来源:MapViewPosition.java


示例4: constructor

import org.oscim.core.Box; //导入依赖的package包/类
@Test
void constructor() {

    double latTopLeft = 52.581;
    double lonTopLeft = 13.396;
    double latBotomRight = 52.579;
    double lonBotomright = 13.400;
    double latCenter = 52.580;
    double lonCenter = 13.398;

    GeoPoint leftTop = new GeoPoint(latTopLeft, lonTopLeft);
    GeoPoint rightBotom = new GeoPoint(latBotomRight, lonBotomright);
    GeoPoint geoPoint = new GeoPoint(latCenter, lonCenter);


    GeoBoundingBoxInt gbb = new GeoBoundingBoxInt(leftTop, rightBotom);
    assertThat("Point must inside Box", gbb.contains(geoPoint));


    Box box = new Box(MercatorProjection.longitudeToX(lonTopLeft)
            , MercatorProjection.latitudeToY(latTopLeft)
            , MercatorProjection.longitudeToX(lonBotomright)
            , MercatorProjection.latitudeToY(latBotomRight));

    box.map2mercator();
    assertThat("Point must inside Box", box.contains(lonCenter, latCenter));

    GeoBoundingBoxInt geoBoundingBox = new GeoBoundingBoxInt(box);
    assertThat("Point must inside Box", geoBoundingBox.contains(geoPoint));

}
 
开发者ID:Longri,项目名称:cachebox3.0,代码行数:32,代码来源:GeoBoundingBoxTest.java


示例5: toLatLngBounds

import org.oscim.core.Box; //导入依赖的package包/类
public static LatLngBounds toLatLngBounds(Box box) {
    double minLon = MercatorProjection.toLongitude(box.xmin);
    double maxLon = MercatorProjection.toLongitude(box.xmax);
    double minLat = MercatorProjection.toLatitude(box.ymax);
    double maxLat = MercatorProjection.toLatitude(box.ymin);
    if (Double.isNaN(minLon) || Double.isNaN(maxLon) || Double.isNaN(minLat) || Double.isNaN(maxLat))
        minLon = maxLon = minLat = maxLat = 0;
    return new LatLngBounds(new LatLng(minLat, minLon), new LatLng(maxLat, maxLon));
}
 
开发者ID:microg,项目名称:android_packages_apps_GmsCore,代码行数:10,代码来源:GmsMapsTypeHelper.java


示例6: getBBox

import org.oscim.core.Box; //导入依赖的package包/类
/**
 * Get the minimal axis-aligned BoundingBox that encloses
 * the visible part of the map. Sets box to map coordinates:
 * xmin,ymin,ymax,ymax
 */
public synchronized void getBBox(Box box, int expand) {
	float[] coords = mViewCoords;
	getMapExtents(coords, expand);

	box.xmin = coords[0];
	box.xmax = coords[0];
	box.ymin = coords[1];
	box.ymax = coords[1];

	for (int i = 2; i < 8; i += 2) {
		box.xmin = Math.min(box.xmin, coords[i]);
		box.xmax = Math.max(box.xmax, coords[i]);
		box.ymin = Math.min(box.ymin, coords[i + 1]);
		box.ymax = Math.max(box.ymax, coords[i + 1]);
	}

	//updatePosition();
	double cs = mPos.scale * Tile.SIZE;
	double cx = mPos.x * cs;
	double cy = mPos.y * cs;

	box.xmin = (cx + box.xmin) / cs;
	box.xmax = (cx + box.xmax) / cs;
	box.ymin = (cy + box.ymin) / cs;
	box.ymax = (cy + box.ymax) / cs;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:32,代码来源:Viewport.java


示例7: Rect

import org.oscim.core.Box; //导入依赖的package包/类
public Rect(Box box) {
	if (DEBUG) {
		assert (xmin <= xmax);
		assert (ymin <= ymax);
	}

	xmin = box.xmin;
	ymin = box.ymin;
	xmax = box.xmax;
	ymax = box.ymax;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:12,代码来源:RTree.java


示例8: set

import org.oscim.core.Box; //导入依赖的package包/类
public void set(Box box) {
	if (DEBUG) {
		assert (box.xmin <= box.xmax);
		assert (box.ymin <= box.ymax);
	}
	xmin = box.xmin;
	ymin = box.ymin;
	xmax = box.xmax;
	ymax = box.ymax;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:11,代码来源:RTree.java


示例9: remove

import org.oscim.core.Box; //导入依赖的package包/类
public boolean remove(Box box, T item) {
	Rect r = getRect();
	r.set(box);
	boolean removed = removeRect(r, item);
	releaseRect(r);
	return removed;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:8,代码来源:RTree.java


示例10: search

import org.oscim.core.Box; //导入依赖的package包/类
public int search(Box bbox, SearchCb<T> cb, Object context) {
	Rect r = getRect();
	r.set(bbox);

	/* NOTE: May want to return search result another way,
	 * perhaps returning the number of found elements here. */
	//int[] foundCount = { 0 };
	//search(mRoot, r, foundCount, cb, context);
	searchStack(r, cb, context);

	releaseRect(r);
	return 0; //foundCount[0];
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:14,代码来源:RTree.java


示例11: getBox

import org.oscim.core.Box; //导入依赖的package包/类
private BoxItem<T> getBox(Box box) {
	BoxItem<T> it = boxPool.get();
	it.x1 = (int) box.xmin;
	it.y1 = (int) box.ymin;
	it.x2 = (int) box.xmax;
	it.y2 = (int) box.ymax;
	return it;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:9,代码来源:QuadTree.java


示例12: remove

import org.oscim.core.Box; //导入依赖的package包/类
@Override
public boolean remove(Box box, T item) {
	BoxItem<T> bbox = getBox(box);
	boolean ok = remove(bbox, item);
	boxPool.release(bbox);
	return ok;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:8,代码来源:QuadTree.java


示例13: search

import org.oscim.core.Box; //导入依赖的package包/类
@Override
public List<T> search(Box bbox, List<T> results) {
	BoxItem<T> box = getBox(bbox);
	search(box, collectCb, results);
	boxPool.release(box);
	return results;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:8,代码来源:QuadTree.java


示例14: GeoBoundingBoxInt

import org.oscim.core.Box; //导入依赖的package包/类
public GeoBoundingBoxInt(Box box) {
    bottomRight = new GeoPoint(box.ymin, box.xmax);
    topLeft = new GeoPoint(box.ymax, box.xmin);
    validate();
}
 
开发者ID:Longri,项目名称:cachebox3.0,代码行数:6,代码来源:GeoBoundingBoxInt.java


示例15: activateSelectedItems

import org.oscim.core.Box; //导入依赖的package包/类
/**
   * When a content sensitive action is performed the content item needs to be
   * identified. This method does that and then performs the assigned task on
   * that item.
   *
   * @return true if event is handled false otherwise
   */
  protected boolean activateSelectedItems(MotionEvent event, ActiveItem task) {
      int size = mItemList.size();
      if (size == 0)
          return false;

      int eventX = (int) event.getX() - mMap.getWidth() / 2;
      int eventY = (int) event.getY() - mMap.getHeight() / 2;
      Viewport mapPosition = mMap.viewport();

      Box box = mapPosition.getBBox(null, 128);
      box.map2mercator();
      box.scale(1E6);

      int nearest = -1;
      int inside = -1;
      double insideY = -Double.MAX_VALUE;

/* squared dist: 50*50 pixel ~ 2mm on 400dpi */
      double dist = 2500;

      for (int i = 0; i < size; i++) {
          Item item = mItemList.get(i);

          if (!box.contains(item.getPoint().longitudeE6,
                  item.getPoint().latitudeE6))
              continue;

          mapPosition.toScreenPoint(item.getPoint(), mTmpPoint);

          float dx = (float) (mTmpPoint.x - eventX);
          float dy = (float) (mTmpPoint.y - eventY);

          MarkerSymbol it = item.getMarker();
          if (it == null)
              it = mMarkerRenderer.mDefaultMarker;

          if (it.isInside(dx, dy)) {
              if (mTmpPoint.y > insideY) {
                  insideY = mTmpPoint.y;
                  inside = i;
              }
          }
          if (inside >= 0)
              continue;

          double d = dx * dx + dy * dy;
          if (d > dist)
              continue;

          dist = d;
          nearest = i;
      }

      if (inside >= 0)
          nearest = inside;

      if (nearest >= 0 && task.run(nearest)) {
          mMarkerRenderer.update();
          mMap.render();
          return true;
      }
      return false;
  }
 
开发者ID:andreynovikov,项目名称:trekarta,代码行数:71,代码来源:ItemizedLayer.java


示例16: insert

import org.oscim.core.Box; //导入依赖的package包/类
public void insert(Box box, T item) {
	Rect r = getRect();
	r.set(box);
	insertRect(r, item, 0);
	releaseRect(r);
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:7,代码来源:RTree.java


示例17: insert

import org.oscim.core.Box; //导入依赖的package包/类
@Override
public void insert(Box box, T item) {
	insert(new BoxItem<T>(box, item));
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:5,代码来源:QuadTree.java


示例18: Item

import org.oscim.core.Box; //导入依赖的package包/类
Item(Box bbox, int val) {
	this.val = val;
	this.bbox = new Box(bbox);
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:5,代码来源:QuadTreeTest.java


示例19: shouldStack2

import org.oscim.core.Box; //导入依赖的package包/类
@Test
public void shouldStack2() {
	RTree<Item> t = new RTree<Item>();
	double[] min = { 0, 0 };
	double[] max = { 1, 1 };

	int numItems = 10000;
	for (int i = 0; i < numItems; i++) {

		Item it = new Item(min, max, i);
		//out.println("insert: " + it.val);
		t.insert(min, max, it);

		min[0]++;
		min[1]++;

		max[0]++;
		max[1]++;

	}
	assertEquals(numItems, t.size());

	min[0] = 0;
	min[1] = 0;

	final ArrayList<Item> results = new ArrayList<Item>();

	Box bbox = new Box(min[0], min[1], max[0], max[1]);

	t.search(bbox, results);

	assertEquals(numItems, results.size());

	//		for (int i = 999; i >= 0; i--) {
	//			Item it = results.remove(i);
	//			boolean removed = t.remove(it.min, it.max, it);
	//			//out.println("REMOVED: " + it + " " + removed);
	//
	//			Assert.assertEquals(i, t.count());
	//		}
	//		Assert.assertEquals(0, t.count());
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:43,代码来源:RTreeTest.java


示例20: insert

import org.oscim.core.Box; //导入依赖的package包/类
public void insert(Box box, T item); 
开发者ID:opensciencemap,项目名称:vtm,代码行数:2,代码来源:SpatialIndex.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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