Exemple #1
0
			HandleGetMapRequestResult HandleGetMapRequest(const WebMapService::GetMapRequest& gmr, const OGRSpatialReference* requestSRS, Image& img)
			{
				assert(img.rawDataType == DT_U8);

				BBox osmBBox;
				if (!TransformBBox(gmr.bbox, osmBBox, requestSRS, OSM_SpatRef))
				{
					return HGMRR_InvalidBBox; // TODO: according to WMS specs bbox may lay outside of valid areas (e.g. latitudes greater than 90 degrees in CRS:84)
				}

				high_resolution_clock::time_point t1 = high_resolution_clock::now();

				HandleGetMapRequestResult result = RasterImg(gmr, osmBBox, requestSRS, img);

				high_resolution_clock::time_point t2 = high_resolution_clock::now();
				duration<double> time_span = duration_cast<duration<double>>(t2 - t1) * 1000.0;
				std::cout << "OSM SDF computation took " << std::setprecision(5) << time_span.count() << " ms" << endl;

				return result;
			}
Exemple #2
0
static void nodeUpdateBB (Node *thisNode) {

	if (thisNode == NULL) return;

	if(thisNode->parent){ /* Si thisNode no es el nodo raíz */
		if(thisNode->gObject){ /* Si thisNode es un nodo hoja */
			TransformBBox(thisNode->container_WC, thisNode->gObject->container, thisNode->placement_WC);
		}else{		
			/* Recorrer los hijos combinando sus BB, y después asignarle esa unión al nodo */
			Node * oneNode;
			oneNode = StartLoop(thisNode->nodeChilds);

			/* Asignar al padre el BB del primer hijo, para no llamar a BoxBox con un BB nulo */
			/* Después se recorren el resto de hijos combinando los BBox, empezando desde el segundo */
			CopyBBox(thisNode->container_WC, oneNode->container_WC);
			oneNode = GetNext(thisNode->nodeChilds);
			while(oneNode) {
				BoxBox(thisNode->container_WC, oneNode->container_WC);
				//PrintBBox(thisNode->container_WC);
				oneNode = GetNext(thisNode->nodeChilds);
			}
		}
	}
}
Exemple #3
0
/**
 * Compute bounding box/tile intersections.
 * \param  winInfo - which window/mural
 * \param  bucketInfo - results of intersection tests
 * \todo XXX someday break this function into a bunch of subroutines, one for
 * each bucketing mode.
 */
static void
doBucket( const WindowInfo *winInfo, TileSortBucketInfo *bucketInfo )
{
	static const CRrecti fullscreen = {-CR_MAXINT, CR_MAXINT, -CR_MAXINT, CR_MAXINT};
	static const CRrecti nullscreen = {0, 0, 0, 0};
	GET_CONTEXT(g);

	/* the bounds should be valid at this point */
	/*CRASSERT(bucketInfo->objectMin.x != FLT_MAX);*/

	/* Init bucketInfo results */
	bucketInfo->pixelBounds = nullscreen;
	/* Initialize the results/hits bitvector.  Each bit represents a server.
	 * If the bit is set, send the geometry to that server.  There are 32
	 * bits per word in the vector.
	 */
	{
		int j;
		for (j = 0; j < CR_MAX_BITARRAY; j++)
			bucketInfo->hits[j] = 0;
	}

	/* We might be broadcasting, *or* we might be defining a display list,
	 * which goes to everyone (currently).
	 */
	if (winInfo->bucketMode == BROADCAST || g->lists.currentIndex) {
		bucketInfo->pixelBounds = fullscreen;
		FILLDIRTY(bucketInfo->hits);
		return;
	}

	/* Check for infinite bounding box values.  If so, broadcast.
	 * This can happen when glVertex4f() is called with w=0.  This
	 * is done in the NVIDIA infinite_shadow_volume demo.
	 */
	if (!FINITE(bucketInfo->objectMin.x) || !FINITE(bucketInfo->objectMax.x)) {
		bucketInfo->pixelBounds = fullscreen;
		FILLDIRTY(bucketInfo->hits);
		return;
	}

	/* When using vertex programs, vertices may get warped/displaced.
	 * This is a way to grow the bounding box a little if needed.
	 */
	if (tilesort_spu.bboxScale != 1.0) {
		GLfloat scale = tilesort_spu.bboxScale;
		/* compute center point of box */
		GLfloat cx = 0.5f * (bucketInfo->objectMin.x + bucketInfo->objectMax.x);
		GLfloat cy = 0.5f * (bucketInfo->objectMin.y + bucketInfo->objectMax.y);
		GLfloat cz = 0.5f * (bucketInfo->objectMin.z + bucketInfo->objectMax.z);
		/* scale bounds relative to center point */
		bucketInfo->objectMin.x = cx + (bucketInfo->objectMin.x - cx) * scale;
		bucketInfo->objectMin.y = cy + (bucketInfo->objectMin.y - cy) * scale;
		bucketInfo->objectMin.z = cz + (bucketInfo->objectMin.z - cz) * scale;
		bucketInfo->objectMax.x = cx + (bucketInfo->objectMax.x - cx) * scale;
		bucketInfo->objectMax.y = cy + (bucketInfo->objectMax.y - cy) * scale;
		bucketInfo->objectMax.z = cz + (bucketInfo->objectMax.z - cz) * scale;
	}

	/*
	 * OK, now do bucketing
	 */
	if (winInfo->bucketMode == TEST_ALL_TILES)
	{
		float xmin, ymin, xmax, ymax, zmin, zmax;
		CRrecti ibounds;
		int i, j;

		if (!TransformBBox(winInfo, 0,
								 /* in */ &bucketInfo->objectMin, &bucketInfo->objectMax,
								 /* out */ &xmin, &ymin, &zmin, &xmax, &ymax, &zmax, &ibounds))
			return; /* not visible, all done */

		/* Explicitly test the bounding box (ibounds) against all tiles on
		 * all servers.
		 */
		for (i=0; i < tilesort_spu.num_servers; i++) 
		{
			const ServerWindowInfo *servWinInfo = winInfo->server + i;
			/* only bother if the stereo left/right flags agree */
			if (servWinInfo->eyeFlags & thread->currentContext->stereoDestFlags) {
				/* 32 bits (flags) per element in hits[] */
				const int node32 = i >> 5;
				const int node = i & 0x1f;

				if (winInfo->matrixSource == MATRIX_SOURCE_SERVERS) {
					/* recompute bounds */
					TransformBBox(winInfo, i,
												&bucketInfo->objectMin,	&bucketInfo->objectMax, /*in*/
												&xmin, &ymin, &zmin, &xmax, &ymax, &ymin, &ibounds);
				}

				bucketInfo->pixelBounds = ibounds;

				for (j = 0; j < servWinInfo->num_extents; j++) 
				{
					if (ibounds.x1 < servWinInfo->extents[j].x2 && 
							ibounds.x2 >= servWinInfo->extents[j].x1 &&
							ibounds.y1 < servWinInfo->extents[j].y2 &&
							ibounds.y2 >= servWinInfo->extents[j].y1) 
					{
						bucketInfo->hits[node32] |= (1 << node);
						break;
					}
				}
			}
		}
		/* all done */
	}