void SoXipHandlerShape::getHandlerPoints( SoMFVec3f& handlerPoint ) { SoMFInt32 dummyCoordIndex; SbBool dummyClosed; extractGeometries( handlerPoint, dummyCoordIndex, dummyClosed ); }
static StatusWith<double> computeGeoNearDistance(const GeoNearParams& nearParams, WorkingSetMember* member) { // // Generic GeoNear distance computation // Distances are computed by projecting the stored geometry into the query CRS, and // computing distance in that CRS. // // Must have an object in order to get geometry out of it. invariant(member->hasObj()); CRS queryCRS = nearParams.nearQuery.centroid.crs; // Extract all the geometries out of this document for the near query OwnedPointerVector<StoredGeometry> geometriesOwned; vector<StoredGeometry*>& geometries = geometriesOwned.mutableVector(); extractGeometries(member->obj, nearParams.nearQuery.field, &geometries); // Compute the minimum distance of all the geometries in the document double minDistance = -1; BSONObj minDistanceObj; for (vector<StoredGeometry*>::iterator it = geometries.begin(); it != geometries.end(); ++it) { StoredGeometry& stored = **it; // NOTE: A stored document with STRICT_SPHERE CRS is treated as a malformed document // and ignored. Since GeoNear requires an index, there's no stored STRICT_SPHERE shape. // So we don't check it here. // NOTE: For now, we're sure that if we get this far in the query we'll have an // appropriate index which validates the type of geometry we're pulling back here. // TODO: It may make sense to change our semantics and, by default, only return // shapes in the same CRS from $geoNear. if (!stored.geometry.supportsProject(queryCRS)) continue; stored.geometry.projectInto(queryCRS); double nextDistance = stored.geometry.minDistance(nearParams.nearQuery.centroid); if (minDistance < 0 || nextDistance < minDistance) { minDistance = nextDistance; minDistanceObj = stored.element.Obj(); } } if (minDistance < 0) { // No distance to report return StatusWith<double>(-1); } if (nearParams.addDistMeta) { if (nearParams.nearQuery.unitsAreRadians) { // Hack for nearSphere // TODO: Remove nearSphere? invariant(SPHERE == queryCRS); member->addComputed(new GeoDistanceComputedData(minDistance / kRadiusOfEarthInMeters)); } else { member->addComputed(new GeoDistanceComputedData(minDistance)); } } if (nearParams.addPointMeta) { member->addComputed(new GeoNearPointComputedData(minDistanceObj)); } return StatusWith<double>(minDistance); }