Discussion:
[Community] Debug messages
Roman Seidl
2015-12-17 07:35:33 UTC
Permalink
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>

Do these messages come from Shapely? If so how can I avoid them?

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
Sean Gillies
2015-12-19 03:04:42 UTC
Permalink
Post by Roman Seidl
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
Trying `CDLL(libgeos_c.so.1)`
Library path: 'libgeos_c.so.1'
DLL: <CDLL 'libgeos_c.so.1', handle 20528420 at 2045c2d0>
Do these messages come from Shapely? If so how can I avoid them?
They do. I'm not familiar with Scapy, but if you raise the logging level in
your application to INFO from DEBUG you won't see these messages.
--
Sean Gillies
Loading...