Hi!

I am using Shapely to determine if a point is within an area. I am doing so 
when storing an item to the database in a pipeline.

Thus in the constructor of the pipeline I read a kml file and then use 
Shapely to test if the point is within the shape.

This works perfectly and when I do so a normal command line .py file I get 
no debug messages. But if i start the process from within Scrapy (even with 
-L ERROR) I keep getting the following debug messages from Shapely:

Trying `CDLL(libgeos_c.so.1)`
Library path: 'libgeos_c.so.1'
DLL: <CDLL 'libgeos_c.so.1', handle 20528420 at 2045c2d0>


*Does Scrapy somehow influence logging in other modules? *

How can I avoid that?

cheers
roman


Code:
from xml.etree import ElementTree
import keytree
from shapely.geometry import Point, shape

class Polygon(object):
    def __init__(self, placemark):
        self.name = int(placemark.find(
'{http://www.opengis.net/kml/2.2}name').text)
        poly = placemark.find('{http://www.opengis.net/kml/2.2}Polygon')
        self.shape = shape(keytree.geometry(poly))

    def contains(self, point):
        return self.shape.contains(point)


class MongoDBPipeline(object):
    
    def __init__(self):
        kmlFile = file("places.kml")
        doc = kmlFile.read()
        kmlFile.close()

        tree = ElementTree.fromstring(doc)
        kmlns = tree.tag.split('}')[0][1:]
        areas = tree.findall(".//{%s}Placemark" % kmlns)
        self.polys = set(Polygon(placemark) for placemark in tree.findall(
".//{%s}Placemark" % kmlns))


    def findLocation(self, point):
        p = Point(float(point[1]), float(point[0]))
        hit = -1
        for poly in self.polys:
            if poly.contains(p):
                if hit < 0 or poly.name < hit:
                    hit = poly.name
        return hit


-- 
You received this message because you are subscribed to the Google Groups 
"scrapy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/scrapy-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to