Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 27 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# RetailTree

RetailTree is a Python library designed for efficient management and querying of spatial data utilizing a tree-based data structure. Specifically, RetailTree employs a VP (Vantage Point) tree for optimized spatial data management.

# Key Features
Expand All @@ -14,34 +15,45 @@ RetailTree is a Python library designed for efficient management and querying of
You can install retailTree via pip:

```
1) clone the repo
2) cd retailTree
3) pip install retailTree-0.0.1-py3-none-any.whl
pip install retailtree
```

# Usage

```
from retailTree import retailTree, Annotation
from retailTree.utils.dist_func import manhattan, euclidean
from retailtree import RetailTree, Annotation
from retailtree.utils.dist_func import manhattan, euclidean

# Create annotation object
ann1 = Annotation(id=1, x_min=2, y_min=1, x_max=3, y_max=2)
ann2 = Annotation(id=2, x_min=1, y_min=2, x_max=2, y_max=3)
ann3 = Annotation(id=3, x_min=2, y_min=2, x_max=3, y_max=3)
ann4 = Annotation(id=4, x_min=3, y_min=2, x_max=4, y_max=3)
ann5 = Annotation(id=5, x_min=2, y_min=3, x_max=3, y_max=4)

annotations = [ann1, ann2, ann3, ann4, ann5]

obj = RetailTree()
# Create retailtree object
rt = RetailTree()

# Adding annotations
obj.add_annotation(id=1, x_min=1, y_min=1, x_max=1, y_max=1)
obj.add_annotation(id=2, x_min=2, y_min=2, x_max=2, y_max=2)
# Adding annotations to retailtree
for ann in annotations:
rt.add_annotation(ann)

# Tree Building
obj.build_tree(dist_func=manhattan)

# Build tree
rt.build_tree(dist_func=euclidean)

# Get neighbors-annotations within radius
obj.find_neighbors(id=961360402, radius=1)
print(rt.neighbors(id=3, radius=1))

# Get Top, Bottom, Right, Left annotations
obj.TBLR(id=961360402, radius=1.4)
print(rt.TBLR(id=3, radius=1, overlap=0.5))

# Get neighboring annotations within a particular angle range
obj.get_neighbors_within_angle(
id=963804130, radius=1, min_angle=0, max_angle=90)
print(rt.neighbors_wa(id=3, radius=1, amin=0, amax=180))

# Get annotation properties
print(rt.get(id=3).get_coords())

```
8 changes: 4 additions & 4 deletions retailtree/retailtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ def __fetching_ann_in_range(self, result_dict, min_angle, max_angle, result_lst)
# if min_angle is None:
return result_lst

def neighbors_wa(self, id: int, radius=1, mina=None, maxa=None):
def neighbors_wa(self, id: int, radius=1, amin=None, amax=None):
"""
Retrieves neighboring elements within a specified angle range around a given element.

Args:
id (int): The identifier of the central element.
radius (float, optional): The radius within which to search for neighbors. Defaults to 1.
mina (min_angle) (float, optional): The minimum angle in degree. Defaults to None.
maxa (max_angle) (float, optional): The maximum angle in degree. Defaults to None.
amin (min_angle) (float, optional): The minimum angle in degree. Defaults to None.
amax (max_angle) (float, optional): The maximum angle in degree. Defaults to None.

Returns:
list: A list of dictionaries containing information about neighboring elements,
Expand All @@ -139,7 +139,7 @@ def neighbors_wa(self, id: int, radius=1, mina=None, maxa=None):
}

self.__fetching_ann_in_range(
result_dict, mina, maxa, result_lst)
result_dict, amin, amax, result_lst)

return result_lst

Expand Down
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from setuptools import setup, find_packages

def read( fname ):

def read(fname):
with open(fname) as fp:
content = fp.read()
return content



setup(
name="retailtree",
version="1.1",
version="1.2",
long_description=read("README.md"),
long_description_content_type='text/markdown',
packages=find_packages(),
Expand Down