Implementing Tracking Management and Geo-Fencing on Table Store


The tracking management system is widely used in daily life, such as take-out delivery tracking, express logistics flows, and vehicle positioning tracking. This scenario is similar to geographic location management. The core points and bottlenecks are in the storage performance and query capability of the database. At the same time, the time fields need to be arranged in a forward order to ensure the tracking point order. On the one hand, the storage service must support low-latency storage and reading of massive data. On the other hand, the storage service must also provide efficient multi-dimensional data retrieval and sorting. Table Store is still competent for tracking management scenarios, and is fully capable of implementing the tracking management system.


Due to safety considerations, motorcycles are restricted to certain areas in a city. A motorcycle rental company, in order to better manage the violation of regulations of motorcycles under its jurisdiction, are to install a positioning system for motorcycles under its jurisdiction and collect motorcycle positions regularly. Motorcycle rental companies can use the tracking management platform to query and collect violations. It can also be used as a basis to remind rental users who violate the rules that they will be blacklisted if they violate the rules too many times;

Table Store

Table Store is used to easily build a management system for motorcycles at the scale of 100 million. SearchIndex function provides geo query and multi-dimensional query capabilities to obtain the tracking of tracked device by sorting time. At the same time, you can create indexes at any time and then complete automatic synchronization, without worrying about inventory data issues.

Preparation for Building

If you are satisfied with the management system for motorcycles at the scale of 100 million implemented based on Table Store and want to start to build your own system, simply follow these steps:

(1) Activate Table Store

Activate the Table Store service in the console. Table Store is out-of-the-box (post-paid) and billed on a pay-as-you-go basis. Table Store also provides a free quota that is sufficient for functional tests. For more information, visit Table Store Console and Free Quota Description.

(2) Create an Instance

Create a Table Store instance in the console and select a region that supports SearchIndex. (Currently the SearchIndex feature has not been commercialized and is supported in the following regions:Beijing, Shanghai, Hangzhou, and Shenzhen. This feature will be gradually available in other regions.)

  • Beta test invitation request: Open a ticket, select”Table Store” > “Product Features and Characteristics” > “Create a Ticket”. The application content is as follows:
  • Question description: Please enter “Apply for SearchIndex beta test invitation”
  • Confidential information: Please enter region + Instance name, for example, Shanghai + myInstanceName

(3) Download SDKs

Use SDKs with SearchIndex (see the official website for more details). Currently, new functions are added for Java, Go, and Node.js SDKs.

$ go get
$ npm install tablestore@4.1.0

(4) Design a Table

The shop search system sample only uses one shop table that mainly includes fields such as shop type, shop name, shop location, average shop ratings, and per capita consumption. The table is designed as follows:

Start Building (Core Code)

(1) Create a Data Table

Users only need to create a motorcycle track table under the instance that has completed the test: Create and manage data tables on the console (they can also directly create data tables using the SDK). Other tables, such as the rental user table and the motorcycle information table, are created as needed. Only the track table is displayed here, and the table name is geo_track.

(2) Create a Data Table Index

Table Store automatically synchronizes full and incremental index data: Users can create and manage indexes through the console (or, they can also create indexes using the SDK)

(3) Data Import

Insert some test data (108 million entries of data — 10,000 motorcycles 70 days 24 hours * 6 ten-minute points — are inserted into the console sample. Users can insert a small amount of test data on the console);

(4) Data Reading

Data reading falls into two types:

List<Query> mustQueries = new ArrayList<Query>();
List<String> polygonList = Arrays.asList(//Geo-fencing, no motorcycle area
String mId = "id00001";
Long timeStart = [2018-11-01timestamp];
Long timeEnd = [2018-11-02timestamp];
GeoPolygonQuery geoPolygonQuery = new GeoPolygonQuery();
TermQuery termQuery = new TermQuery();
RangeQuery rangeQuery = new RangeQuery();
rangeQuery.setFrom(ColumnValue.fromDouble(timeStart, true);
rangeQuery.setTo(ColumnValue.fromDouble(timeEnd, false);
BoolQuery boolQuery = new BoolQuery();



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud


Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website: