Searching for evenly distributed GPS coordinates across an area

I have a collection of data points representing mountain peaks in the European Alps that I would like to showcase on a map. To prevent cluttering the user interface, I currently retrieve the highest peaks within the visible area of the map by sorting them based on elevation and selecting a specific number.

await prisma.mountain.findMany({
    where: {
      lat: { gt: lat_min, lt: lat_max },
      lng: { gt: lng_min, lt: lng_max },
    },
    orderBy: {
      elevation: "desc",
    },
    take: 20,
  });

This approach works well when the map is zoomed in, but as the user zooms out, the results tend to cluster around regions with higher mountains quite quickly.

Is there a way to adjust my query to evenly distribute the results across the queried area?

I attempted to focus more on the center of the area by adjusting the bounds of my query as the user zooms out. However, this method did not yield satisfactory results when zoomed out extensively.

Answer №1

My solution involved splitting the terrain into a grid and analyzing all the peaks within each section. This approach led to a harmonious distribution of data.

To ensure that the peaks remain visible even when the map is shifted, an alternative method could be dividing the entire globe into cells and loading those intersecting with the current map bounds.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Typescript integration with Sequelize CLI for efficient database migrations

According to the Sequelize documentation, it claims to work with Typescript. However, for it to be fully functional in a production environment, DB migration scripts are necessary. The issue arises when using the Sequelize CLI as it only generates and runs ...

PHP variable missing "+" sign at the end after post operation

I have encountered a unique problem that I cannot seem to find anywhere else. My issue lies in adding grades ending with a plus sign, such as B+, C+ or D+. I am able to add grades like A-, B-, C- and D- without any problem, but when it comes to adding a g ...

Error: The token 'export' in d3zoom is causing a syntax issue

I'm encountering issues with executing tests in Angular: ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export {default as zoom} from "./zoom.js"; ...

Is it possible for us to perform an addition operation on two or more items that belong to the same

I am faced with a challenge involving 3 objects of the same type, each having different values for their properties. My goal is to add them together as illustrated below: Consider this scenario: objA = { data: { SH: { propertyA: 0, propertyB: ...

Store Instagram API subscription details into a database

My goal is to save pictures with a specific tag from Instagram into a database. I've been successful up until the point of writing to the database. The subscription part is working fine, as I received confirmation from the Instagram API site: {" ...

Steps for opening standalone angular2 and TypeScript project in visual studio: A guide to launching your project

What is the process for accessing an Angular2 and TypeScript project in Visual Studio without needing npm or Node.js? I require the ability to open the project on a computer that is not connected to a network. Many thanks ...

Error: Accessing Undefined Property in Node-SQLite

I recently started developing a REST API for garden-related data collected by an Arduino using node-sqlite3. Basic queries like retrieving all the database information are working fine. However, I am facing challenges when trying to retrieve data based on ...

Sending Disabled Form Field Input Value in Angular 2 POST Request

I'm working on a form with an email field that I want to populate using interpolation. However, I also want to prevent users from changing the email address once it's displayed. To achieve this, I tried adding the disabled attribute to the input ...

How can we strengthen the type checking when defining the sorting function for json properties?

When dealing with a json structure from a service that contains .attributes json values, I often find myself needing to sort either by id from the DTO or by several attributes from the IContactsAttributes. The microservice returns this specific structure: ...

What function does the ng-template serve when encapsulated within an ng-select component?

Upon observing various instances of ng-select, I've noticed that it often involves wrapping a ng-template, as exemplified below: <ng-select [items]="cities" [(ngModel)]="selectedCity" bindLabel="name" bindV ...

SQL Server's function to convert hours into days: "CONVERT(DATETIME,

Set up Table ( id as integer auto_increment, WorkHours as integer ) I have created a table where I store work hours as integers. My goal is to present the work hours in DD:HH format. Can anyone help me achieve this? ...

Is it possible to interchange the positions of two components in a routing system?

driver-details.component.ts @Component({ selector: 'app-driver-details', templateUrl: './driver-details.component.html', styleUrls: ['./driver-details.component.css'] }) export class DriverDetailsComponent implements OnI ...

Disabling specific time slots in the mat select functionality

I have a scenario where I need to display time slots at 30-minute intervals using Mat Select. export const TIME=["12:00 AM","12:30 AM","01:00 AM","01:30 AM","02:00 AM","02:30 AM","03:00 AM&qu ...

Receiving data from a service in Angular 2 with rxjs subscribe throws an error: it is not a

I've recently started working with Angular and I'm encountering an issue when trying to pass the _newArray to my child component using a shared service. Service fetchData(): Observable < any > { return forkJoin(this.fetchQuestions(), th ...

Derby ALERT 54038: The number of nested triggers has exceeded the maximum allowed depth

I'm attempting to trigger a function that clears the owner_notif_sta field to null after updating or inserting data if the owner_id field is null. Both owner_id and owner_notif_sta come from the same table. Here is the trigger code I'm using: C ...

Converting an Ajax request from JavaScript to jQuery

I am new to Ajax and trying to convert an ajax request from javascript to jquery without success. Here is the javascript code snippet I am working with: function aaa(track_id) { var req = new XMLHttpRequest(); req.open("get", "list.php?tr=" + track_id, ...

Utilize AJAX to update an SQL database

Having trouble using a code copied from a website: <?php if (isset($_POST['action'])) { $field = $_POST['db_field']; $value = $_POST['db_value']; $link = mysql_connect("localhost", "root", ""); mysql_select_db("login", $li ...

The functionality of Microsoft Access UNION is currently restricting the length of long text fields to only 255 characters

Currently, I am facing an issue while using a UNION statement to merge the data from two tables. The problem arises when the data has fields with a length exceeding 255 characters as they are truncated at the 255th character mark. Strangely, when I use a ...

SQL Server: transforming vertical data into a horizontal format (pivot with a unique twist)

I have been attempting to condense multiple rows of a table into one row with multiple columns, but I have not found a suitable method yet. The main issue is that the table does not contain any 'heading' data, which makes it difficult to use the ...

Unable to fetch data from URL in Angular using the HttpClientModule

I have a goal in my application to retrieve data from the following URL and showcase it within the app: https://jsonplaceholder.typicode.com/posts/1 The issue I'm encountering is that the data is not being displayed in my app. The console is showing ...