# Introducing Sync for Geospatial Data

Geospatial queries have been one of the most requested features in the Atlas Device SDKs and Realm for a long time. As of today, we have added support in Kotlin, JS, and .NET with the rest to follow soon. Geospatial queries unlock a powerful set of location-based applications, and today we will look at how to leverage the power of using them with sync to make your application both simple and efficient. 

The dataset used in the following examples can be downloaded to your own database by following the instructions in the geospatial queries docs.

Let’s imagine that we want to build a “restaurants near me” application where the primary use case is to provide efficient, offline-first search for restaurants within a walkable distance of the user’s current location. How should we design such an app? Let’s consider a few options:

1. We could send the user’s location-based queries to the server and have them processed there. This promises to deliver accurate results but is bottlenecked on the server’s performance and may not scale well. We would like to avoid the frustrating user experience of having to wait on a loading icon after entering a search.
2. We could load relevant/nearby data onto the user’s device and do the search locally. This promises to deliver a fast search time and will be accurate to the degree that the data cached on the user’s device is up to date for the current location. But the question is, how do we decide what data to send to the device, and how do we keep it up to date?

With flexible sync and geospatial queries, we now have the tools to build the second solution, and it is much more efficient than an app that uses a REST API to fetch data.

## Filtering by radius

A simple design will be to subscribe to all restaurant data that is within a reasonable walkable distance from the user’s current location — let’s say .5 kilometer (~0.31 miles). To enable geospatial queries to work in flexible sync, your data has to be in the right shape. For complete instructions on how to configure your app to support geospatial queries in sync, see the documentation. But basically, the location field has to be added to the list of queryable fields. The sync schema will look something like this:

 . Syncing these types of shapes is in our upcoming roadmap, but until that is available, you can query the MongoDB data using the Atlas App Services API to get the BSON representation and parse that to build a GeoPolygon that Realm queries accept. Being able to filter on arbitrary shapes opens up all sorts of interesting geofencing applications, granting the app the ability to react to a change in location.

The ability to use flexible sync with geospatial queries makes it simple to design an efficient location-aware application. We are excited to see what you will use these features to create!

> **Ready to get started now?**
>
> Install one of our SDKs — start your journey with our docs or jump right into example projects with source code.
>
> Then, register for Atlas to connect to Atlas Device Sync, a fully-managed mobile backend as a service. Leverage out-of-the-box infrastructure, data synchronization capabilities, network handling, and much more to quickly launch enterprise-grade mobile apps. 
>
> Finally, let us know what you think and get involved in our forums. See you there!

  [1]: https://images.contentstack.io/v3/assets/blt39790b633ee0d5a7/blt1a44f04ba566d1ae/656fabb4c6be9315f5e0128a/image6.png
  [2]: https://images.contentstack.io/v3/assets/blt39790b633ee0d5a7/blt344682eee682e5dc/656fabe4d4041c844014bd01/image7.png
  [3]: https://images.contentstack.io/v3/assets/blt39790b633ee0d5a7/bltf2cab77d982c9d77/656fabfbc7fbbbe84612fff0/maps.jpg
  [4]: https://images.contentstack.io/v3/assets/blt39790b633ee0d5a7/bltf426b51421040dc0/656fac2d358dcdd08dd73ca0/image5.png
  [5]: https://images.contentstack.io/v3/assets/blt39790b633ee0d5a7/blt18e2b28f3f616b7f/656fac56841cdf44f874bb27/image3.png