Пример #1
0
    def __call__(self, r):
        '''
        Adds the specified record to the aggregate value.
        '''
        self._calls += 1
        for i, c in enumerate(self._c):
            self._c[i] = self._af[i][1](c, r[i])


engines = []
counters = []

# The query stream contains only a single query box.
query_streamer = ArrayStreamer(query_schema, [
    (query, ),
])
engines.append(query_streamer)

counties_source = Rtree(counties_file, 'counties.the_geom')

counties_accessor = DataAccessor(
    query_streamer.output(),
    counties_source,
    FindRange,
)
engines.append(counties_accessor)

demux = Demux(counties_accessor.output())

Пример #2
0
    try:
        if g1.is_valid and g2.is_valid:
            i = g1.intersection(g2)
            return Geometry(i)
        else:
            return None
    except:
        return None


engines = []
counters = []

# The query stream contains only a single query box.
query_streamer = ArrayStreamer(query_schema, [
    (query, ),
])
engines.append(query_streamer)

# Query the states from the data source.
states_source = Rtree(states_file, 'states.the_geom')
states_accessor = DataAccessor(query_streamer.output(), states_source,
                               FindRange)
engines.append(states_accessor)

# Trim the states to the query region.
states_select = Select(
    states_accessor.output(),
    UniversalSelect(
        states_accessor.output().schema(),
        {
Пример #3
0
#############################################################
#
# TEST 1
#
#############################################################

# schema definition of the query stream
query_schema = Schema()
query_schema.append(Attribute('age', IntInterval))

# query stream generator from array
query_streamer = ArrayStreamer(query_schema, [
        (IntInterval(1, 3),),
        (IntInterval(2, 5),),
        (IntInterval(1, 3),),
        (IntInterval(1, 3),),
        (IntInterval(2, 5),),
        (IntInterval(2, 5),),
        (IntInterval(1, 3),),
        (IntInterval(2, 5),),
])

# schema definition of the data stream
data_schema = Schema()
data_schema.append(Attribute('name', str))
data_schema.append(Attribute('age', int))

data_schema.append(Attribute('rowid', int, True))
data_source = DBTable('test.db', 'person', data_schema)

# create a data accessor
data_accessor = DataAccessor(
Пример #4
0
        return self._calls

    def __call__(self, r):
        """
        Adds the specified record to the aggregate value.
        """
        self._calls += 1
        for i, c in enumerate(self._c):
            self._c[i] = self._af[i][1](c, r[i])


engines = []
counters = []

# The query stream contains only a single query box.
query_streamer = ArrayStreamer(query_schema, [(query,)])
engines.append(query_streamer)

counties_source = Rtree(counties_file, "counties.the_geom")

counties_accessor = DataAccessor(query_streamer.output(), counties_source, FindRange)
engines.append(counties_accessor)

demux = Demux(counties_accessor.output())


def intersection(a, b):
    g1 = a.geom()
    g2 = b.geom()
    try:
        if g1.is_valid and g2.is_valid:
Пример #5
0
        return self._calls

    def __call__(self, r):
        '''
        Adds the specified record to the aggregate value.
        '''
        self._calls += 1
        for i, c in enumerate(self._c):
            self._c[i] = self._af[i][1](c, r[i])


engines = []

# The query stream contains only a single query.
query_streamer = ArrayStreamer(query_schema, [
    (IntInterval(0, int(1E10)), ),
])
engines.append(query_streamer)

# Create a family data source: a table in the input database.
family_source = DBTable(input_file, 'family', family_schema)
# Data accessor for the species data source.
family_accessor = DataAccessor(query_streamer.output(), family_source,
                               FindRange)
engines.append(family_accessor)

# A group mini-engine to split the family IDs into groups.
family_id_grouper = Group(family_accessor.output(), {
    'family.id': lambda a, b: a == b
})
engines.append(family_id_grouper)
Пример #6
0
#############################################################
#
# TEST 1
#
#############################################################

# schema definition of the query stream
query_schema = Schema()
query_schema.append(Attribute('age', IntInterval))

# query stream generator from array
query_streamer = ArrayStreamer(query_schema, [
    (IntInterval(1, 3), ),
    (IntInterval(2, 5), ),
    (IntInterval(1, 3), ),
    (IntInterval(1, 3), ),
    (IntInterval(2, 5), ),
    (IntInterval(2, 5), ),
    (IntInterval(1, 3), ),
    (IntInterval(2, 5), ),
])

# schema definition of the data stream
data_schema = Schema()
data_schema.append(Attribute('name', str))
data_schema.append(Attribute('age', int))

data_schema.append(Attribute('rowid', int, True))
data_source = DBTable('test.db', 'person', data_schema)

# create a data accessor
data_accessor = DataAccessor(query_streamer.output(), data_source, FindRange)
Пример #7
0
#            print '--> %s : %s' % (r[p[0]], p[1](r[p[0]]))
            if not p[1](r[p[0]]):
                return False
        return True    

#############################################################
#
# Query
#
#############################################################

engines = []

# The query stream contains only a single query box.
query_streamer = ArrayStreamer(query_schema, [
        (query,),
        StopWord(),
])
engines.append(query_streamer)

#############################################################
#
# States
#
#############################################################

states_query = Select(
    query_streamer.output(),
    UniversalSelect(
        query_streamer.output().schema(),
        {
            'states.geom': {
Пример #8
0
#############################################################
#
# TEST 1
#
#############################################################

# schema definition of the query stream
query_schema = Schema()
query_schema.append(Attribute('age', IntInterval))

# query stream generator from array
query_streamer = ArrayStreamer(query_schema, [
    (IntInterval(1, 3), ),
    (IntInterval(2, 5), ),
    (IntInterval(1, 3), ),
    (IntInterval(1, 3), ),
    (IntInterval(2, 5), ),
    (IntInterval(2, 5), ),
    (IntInterval(1, 3), ),
    (IntInterval(2, 5), ),
])

demux = Demux(query_streamer.output())

# schema definition of the data stream
data_schema = Schema()
data_schema.append(Attribute('name', str))
data_schema.append(Attribute('age', int))

data_schema.append(Attribute('rowid', int, True))
data_source = DBTable('test.db', 'person', data_schema)
Пример #9
0
#############################################################
#
# TEST 1
#
#############################################################

# schema definition of the query stream
query_schema = Schema()
query_schema.append(Attribute('age', IntInterval))

# query stream generator from array
query_streamer = ArrayStreamer(query_schema, [
        (IntInterval(1, 3),),
        (IntInterval(2, 5),),
        (IntInterval(1, 3),),
        (IntInterval(1, 3),),
        (IntInterval(2, 5),),
        (IntInterval(2, 5),),
        (IntInterval(1, 3),),
        (IntInterval(2, 5),),
])

demux = Demux(query_streamer.output())

# schema definition of the data stream
data_schema = Schema()
data_schema.append(Attribute('name', str))
data_schema.append(Attribute('age', int))

data_schema.append(Attribute('rowid', int, True))
data_source = DBTable('test.db', 'person', data_schema)
Пример #10
0
            if not p[1](r[p[0]]):
                return False
        return True


#############################################################
#
# Query
#
#############################################################

engines = []

# The query stream contains only a single query box.
query_streamer = ArrayStreamer(query_schema, [
    (query, ),
    StopWord(),
])
engines.append(query_streamer)

#############################################################
#
# States
#
#############################################################

states_query = Select(
    query_streamer.output(),
    UniversalSelect(
        query_streamer.output().schema(), {
            'states.geom': {
                'type': Geometry,