Skip to content

Commit

Permalink
[UPD] update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tushar1854 committed May 20, 2024
1 parent 2238421 commit a747671
Showing 1 changed file with 42 additions and 11 deletions.
53 changes: 42 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,24 @@ RetailTree is a Python library designed for efficient management and querying of

You can install retailTree via pip:

```
```python
pip install retailtree
```

# Usage

```
# Import necessary modules and functions
### Import necessary modules and functions

```python
# Imports
from retailtree import RetailTree, Annotation
from retailtree.utils.dist_func import manhattan, euclidean
import json
```

### Method 1: Annotation Creation via File Import

```python
# Define the path to the JSON file containing annotations
file_path = './tests/test_data/test_data.json'

Expand All @@ -42,21 +48,46 @@ for ann in annotations:
ann_obj = Annotation(id=ann['id'], x_min=ann['x_min'], y_min=ann['y_min'], x_max=ann['x_max'], y_max=ann['y_max'])
# Add the created Annotation object to the RetailTree
rt.add_annotation(ann_obj)
```

# OR

### Method 2: Manual Annotation Creation

```python
# 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]

# Create retailtree object
rt = RetailTree()

# Adding annotations to retailtree
for ann in annotations:
rt.add_annotation(ann)
```

## Operations

### Retail Tree Operation

# Build the spatial tree structure using the euclidean distance function
```python
# Build the retail tree structure using the euclidean distance function
rt.build_tree(dist_func=euclidean)

# Retrieve and print annotations within a radius of 1 from the annotation with id=3
# Retrieve and print annotations within a radius.
print(rt.neighbors(id=3, radius=1))

# Retrieve and print the Top, Bottom, Left, and Right neighboring annotations
# of the annotation with id=3 within a radius of 1 and a minimum overlap of 0.5
# Retrieve and print the Top, Bottom, Left, and Right neighboring annotations.
print(rt.TBLR(id=3, radius=1, overlap=0.5))

# Retrieve and print neighboring annotations of the annotation with id=3
# within a radius of 1 and angle range from 0 to 180 degrees
print(rt.neighbors_wa(id=3, radius=1, amin=0, amax=180))
# Retrieve and print neighboring annotations of the annotation.
print(rt.neighbors_wa(id=3, radius=2, amin=0, amax=180))

# Retrieve and print the coordinates of the annotation with id=3
# Retrieve and print the coordinates of the annotation.
print(rt.get(id=3).get_coords())
```

0 comments on commit a747671

Please sign in to comment.