Ejemplo n.º 1
0
    bool GeoParser::parseCap(const BSONObj& obj, CapWithCRS *out) {
        if (isLegacyCenter(obj)) {
            BSONObjIterator typeIt(obj);
            BSONElement type = typeIt.next();
            BSONObjIterator objIt(type.embeddedObject());
            BSONElement center = objIt.next();
            if (!parseLegacyPoint(center.Obj(), &out->circle.center)) { return false; }
            BSONElement radius = objIt.next();
            out->circle.radius = radius.number();
            out->crs = FLAT;
        } else {
            verify(isLegacyCenterSphere(obj));
            BSONObjIterator typeIt(obj);
            BSONElement type = typeIt.next();
            BSONObjIterator objIt(type.embeddedObject());
            BSONObj centerObj = objIt.next().Obj();

            S2Point centerPoint;
            BSONObjIterator it(centerObj);
            BSONElement x = it.next();
            BSONElement y = it.next();
            centerPoint = coordToPoint(x.Number(), y.Number());
            BSONElement radiusElt = objIt.next();
            double radius = radiusElt.number();
            out->cap = S2Cap::FromAxisAngle(centerPoint, S1Angle::Radians(radius));
            out->circle.radius = radius;
            out->circle.center = Point(x.Number(), y.Number());
            out->crs = SPHERE;
        }
        return true;
    }
Ejemplo n.º 2
0
 void GeoParser::parseLegacyCenter(const BSONObj &obj, Point *centerOut, double *radiusOut) {
     BSONObjIterator objIt(obj);
     BSONElement center = objIt.next();
     parseLegacyPoint(center.Obj(), centerOut);
     BSONElement radius = objIt.next();
     *radiusOut = radius.number();
 }
Ejemplo n.º 3
0
void PlainTriples::load(ModifiableTriples &triples, ProgressListener *listener) {
	triples.sort(order);

	IntermediateListener iListener(listener);

	iListener.setRange(0,33);
	iListener.notifyProgress(0, "PlainTriples Importing subjects");
	IteratorTripleID *itS = triples.searchAll();
	ComponentIterator subjIt(itS, SUBJECT);
	streamX->add(subjIt);
	delete itS;

	iListener.setRange(33, 66);
	iListener.notifyProgress(0, "PlainTriples Importing predicates");
	IteratorTripleID *itP = triples.searchAll();
	ComponentIterator predIt(itP, PREDICATE);
	streamY->add(predIt);
	delete itP;

	iListener.setRange(66, 100);
	iListener.notifyProgress(0, "PlainTriples Importing objects");
	IteratorTripleID *itO = triples.searchAll();
	ComponentIterator objIt(itO, OBJECT);
	streamZ->add(objIt);
	delete itO;
}
Ejemplo n.º 4
0
static bool indexCompatibleMaxMin(const BSONObj& obj,
                                  const CollatorInterface* queryCollator,
                                  const IndexEntry& indexEntry) {
    BSONObjIterator kpIt(indexEntry.keyPattern);
    BSONObjIterator objIt(obj);

    const bool collatorsMatch =
        CollatorInterface::collatorsMatch(queryCollator, indexEntry.collator);

    for (;;) {
        // Every element up to this point has matched so the KP matches
        if (!kpIt.more() && !objIt.more()) {
            return true;
        }

        // If only one iterator is done, it's not a match.
        if (!kpIt.more() || !objIt.more()) {
            return false;
        }

        // Field names must match and be in the same order.
        BSONElement kpElt = kpIt.next();
        BSONElement objElt = objIt.next();
        if (!mongoutils::str::equals(kpElt.fieldName(), objElt.fieldName())) {
            return false;
        }

        // If the index collation doesn't match the query collation, and the min/max obj has a
        // boundary value that needs to respect the collation, then the index is not compatible.
        if (!collatorsMatch && CollationIndexKey::isCollatableType(objElt.type())) {
            return false;
        }
    }
}
Ejemplo n.º 5
0
 void GeoParser::parseLegacyCenter(const BSONObj &obj, Circle *out) {
     BSONObjIterator typeIt(obj);
     BSONElement type = typeIt.next();
     BSONObjIterator objIt(type.embeddedObject());
     BSONElement center = objIt.next();
     parseLegacyPoint(center.Obj(), &out->center);
     BSONElement radius = objIt.next();
     out->radius = radius.number();
 }
Ejemplo n.º 6
0
 bool GeoParser::isLegacyCenter(const BSONObj &obj) {
     BSONObjIterator objIt(obj);
     BSONElement center = objIt.next();
     if (!center.isABSONObj()) { return false; }
     if (!isLegacyPoint(center.Obj())) { return false; }
     if (!objIt.more()) { return false; }
     BSONElement radius = objIt.next();
     if (!radius.isNumber()) { return false; }
     return true;
 }
Ejemplo n.º 7
0
 void GeoParser::parseLegacyCenterSphere(const BSONObj &obj, S2Cap *out) {
     BSONObjIterator typeIt(obj);
     BSONElement type = typeIt.next();
     BSONObjIterator objIt(type.embeddedObject());
     BSONElement center = objIt.next();
     S2Point centerPoint;
     parseLegacyPoint(center.Obj(), &centerPoint);
     BSONElement radiusElt = objIt.next();
     double radius = radiusElt.number();
     *out = S2Cap::FromAxisAngle(centerPoint, S1Angle::Radians(radius));
 }
Ejemplo n.º 8
0
 static bool isLegacyCenter(const BSONObj &obj) {
     BSONObjIterator typeIt(obj);
     BSONElement type = typeIt.next();
     if (!type.isABSONObj()) { return false; }
     bool isCenter = mongoutils::str::equals(type.fieldName(), "$center");
     if (!isCenter) { return false; }
     BSONObjIterator objIt(type.embeddedObject());
     BSONElement center = objIt.next();
     if (!center.isABSONObj()) { return false; }
     if (!isLegacyPoint(center.Obj())) { return false; }
     if (!objIt.more()) { return false; }
     BSONElement radius = objIt.next();
     if (!radius.isNumber()) { return false; }
     return true;
 }
Ejemplo n.º 9
0
 void S2AccessMethod::getLiteralKeysArray(const BSONObj& obj, BSONObjSet* out) const {
     BSONObjIterator objIt(obj);
     if (!objIt.more()) {
         // Empty arrays are indexed as undefined.
         BSONObjBuilder b;
         b.appendUndefined("");
         out->insert(b.obj());
     } else {
         // Non-empty arrays are exploded.
         while (objIt.more()) {
             BSONObjBuilder b;
             b.appendAs(objIt.next(), "");
             out->insert(b.obj());
         }
     }
 }
Ejemplo n.º 10
0
 static bool isLegacyCenterSphere(const BSONObj &obj) {
     BSONObjIterator typeIt(obj);
     BSONElement type = typeIt.next();
     if (!type.isABSONObj()) { return false; }
     bool isCenterSphere = mongoutils::str::equals(type.fieldName(), "$centerSphere");
     if (!isCenterSphere) { return false; }
     BSONObjIterator objIt(type.embeddedObject());
     BSONElement center = objIt.next();
     if (!center.isABSONObj()) { return false; }
     if (!isLegacyPoint(center.Obj())) { return false; }
     // Check to make sure the points are valid lng/lat.
     BSONObjIterator coordIt(center.Obj());
     BSONElement lng = coordIt.next();
     BSONElement lat = coordIt.next();
     if (!isValidLngLat(lng.Number(), lat.Number())) { return false; }
     if (!objIt.more()) { return false; }
     BSONElement radius = objIt.next();
     if (!radius.isNumber()) { return false; }
     return true;
 }
Ejemplo n.º 11
0
    static bool indexCompatibleMaxMin(const BSONObj& obj, const BSONObj& keyPattern) {
        BSONObjIterator kpIt(keyPattern);
        BSONObjIterator objIt(obj);

        for (;;) {
            // Every element up to this point has matched so the KP matches
            if (!kpIt.more() && !objIt.more()) {
                return true;
            }

            // If only one iterator is done, it's not a match.
            if (!kpIt.more() || !objIt.more()) {
                return false;
            }

            // Field names must match and be in the same order.
            BSONElement kpElt = kpIt.next();
            BSONElement objElt = objIt.next();
            if (!mongoutils::str::equals(kpElt.fieldName(), objElt.fieldName())) {
                return false;
            }
        }
    }
Ejemplo n.º 12
0
QStringList FMPDFFontExtractor::list()
{
	if(!document)
		return mfont.keys();
	
	if(cachedList)
		return mfont.keys();
	else
		cachedList = true;
	
	PoDoFo::TCIVecObjects objIt( document->GetObjects().begin() );
	PoDoFo::PdfName pType("Type");
	PoDoFo::PdfName pSubtype("Subtype");
	PoDoFo::PdfName pFont("Font");
	PoDoFo::PdfName pType1("Type1");
	PoDoFo::PdfName pTrueType("TrueType");
	PoDoFo::PdfName pFontDescriptor( "FontDescriptor" );
	PoDoFo::PdfName pFontFile( "FontFile" );
	PoDoFo::PdfName pFontFile3( "FontFile3" );
	PoDoFo::PdfName pFontName( "FontName" );
	
	while( objIt != document->GetObjects().end() )
	{
		PoDoFo::PdfObject* obj(*objIt);	
		if ( obj->IsDictionary() )
		{
			if(obj->GetIndirectKey(pType))
			{
				PoDoFo::PdfName type( obj->GetIndirectKey(pType)->GetName() );
				if(type == pFont)
				{
					if(obj->GetIndirectKey( pSubtype ))
					{
						PoDoFo::PdfName subtype ( obj->GetIndirectKey( pSubtype )->GetName() );
						if ((subtype == pType1) ||  (subtype == pTrueType))
						{
							PoDoFo::PdfObject * fontDescriptor ( obj->GetIndirectKey ( pFontDescriptor ) );
							if (fontDescriptor )
							{
								bool hasFile(false);
								PoDoFo::PdfObject * fontFile ( fontDescriptor->GetIndirectKey ( pFontFile ) );
								if ( !fontFile )
								{
									fontFile = fontDescriptor->GetIndirectKey(pFontFile3) ;
									if ( !fontFile )
										qWarning ( "Font not embedded not supported yet" );
									else
										hasFile = true;
			
								}
								else
									hasFile = true;
								if(hasFile)
								{
									PoDoFo::PdfName fontName(fontDescriptor->GetIndirectKey(pFontName)->GetName());
									if(1)
									{
										QString n(QString::fromStdString( fontName.GetName() ));
										mfont[n] = fontFile;
										// we know naming it pfb is wrong 
										mType[n] = (subtype == pType1) ? "pfb" : "ttf";
									}
									else
										qDebug()<<"Error: no /FontName key";
								}
							}
		
						}
					}
				}
			}
		}
		objIt++;
	}
	
	return mfont.keys();
	
}