MapLibre Native C API
Public C ABI for the MapLibre Native wrapper.
Loading...
Searching...
No Matches
projection.h File Reference

Go to the source code of this file.

Data Structures

struct  mln_map_projection_camera_result

Typedefs

typedef struct mln_map_projection_camera_result mln_map_projection_camera_result

Functions

mln_status mln_map_projection_create (const mln_map_view *view, mln_map_projection *out_projection, mln_diagnostic *out_diagnostic)
void mln_map_projection_release (mln_map_projection projection)
mln_status mln_map_projection_get_camera (mln_map_projection projection, mln_map_projection_camera_result *out_result, mln_diagnostic *out_diagnostic)
mln_status mln_map_projection_set_camera (mln_map_projection projection, const mln_camera_options *camera, mln_diagnostic *out_diagnostic)
mln_status mln_map_projection_pixel_for_lat_lng (mln_map_projection projection, mln_lat_lng coordinate, mln_screen_point *out_point, mln_diagnostic *out_diagnostic)
mln_status mln_map_projection_lat_lng_for_pixel (mln_map_projection projection, mln_screen_point point, mln_lat_lng *out_coordinate, mln_diagnostic *out_diagnostic)
mln_status mln_map_projection_lat_lng_for_pixel_unwrapped (mln_map_projection projection, mln_screen_point point, mln_lat_lng *out_coordinate, mln_diagnostic *out_diagnostic)
mln_status mln_map_projection_pixels_for_lat_lngs (mln_map_projection projection, const mln_lat_lng *coordinates, size_t coordinate_count, mln_screen_point *out_points, mln_diagnostic *out_diagnostic)
mln_status mln_map_projection_lat_lngs_for_pixels (mln_map_projection projection, const mln_screen_point *points, size_t point_count, mln_lat_lng *out_coordinates, mln_diagnostic *out_diagnostic)
mln_status mln_map_projection_lat_lngs_for_pixels_unwrapped (mln_map_projection projection, const mln_screen_point *points, size_t point_count, mln_lat_lng *out_coordinates, mln_diagnostic *out_diagnostic)
mln_status mln_map_projection_meters_per_pixel_at_latitude (mln_map_projection projection, double latitude, double *out_meters_per_pixel, mln_diagnostic *out_diagnostic)
mln_status mln_projected_meters_for_lat_lng (mln_lat_lng coordinate, mln_projected_meters *out_meters, mln_diagnostic *out_diagnostic)
mln_status mln_lat_lng_for_projected_meters (mln_projected_meters meters, mln_lat_lng *out_coordinate, mln_diagnostic *out_diagnostic)

Detailed Description

Convert between coordinates, screen points, and projected meters.

Typedef Documentation

◆ mln_map_projection_camera_result

typedef struct mln_map_projection_camera_result mln_map_projection_camera_result

A projection's camera, as mln_map_projection_get_camera() reports it.

Function Documentation

◆ mln_lat_lng_for_projected_meters()

mln_status mln_lat_lng_for_projected_meters ( mln_projected_meters meters,
mln_lat_lng * out_coordinate,
mln_diagnostic * out_diagnostic )

Converts meters in the Web Mercator projection to a coordinate.

◆ mln_map_projection_create()

mln_status mln_map_projection_create ( const mln_map_view * view,
mln_map_projection * out_projection,
mln_diagnostic * out_diagnostic )

Creates a projection that converts coordinates for one view of a map.

Create it from the view of an mln_map_snapshot or an mln_render_frame_result. The projection doesn't follow the map, so create a new one after the map's camera or size changes.

◆ mln_map_projection_get_camera()

mln_status mln_map_projection_get_camera ( mln_map_projection projection,
mln_map_projection_camera_result * out_result,
mln_diagnostic * out_diagnostic )

Reads the projection's camera.

◆ mln_map_projection_lat_lng_for_pixel()

mln_status mln_map_projection_lat_lng_for_pixel ( mln_map_projection projection,
mln_screen_point point,
mln_lat_lng * out_coordinate,
mln_diagnostic * out_diagnostic )

Finds the coordinate at a screen point.

The longitude stays between -180 and 180.

◆ mln_map_projection_lat_lng_for_pixel_unwrapped()

mln_status mln_map_projection_lat_lng_for_pixel_unwrapped ( mln_map_projection projection,
mln_screen_point point,
mln_lat_lng * out_coordinate,
mln_diagnostic * out_diagnostic )

Finds the coordinate at a screen point, without wrapping its longitude.

The longitude can fall outside -180 to 180, to show which copy of the world the point is in.

◆ mln_map_projection_lat_lngs_for_pixels()

mln_status mln_map_projection_lat_lngs_for_pixels ( mln_map_projection projection,
const mln_screen_point * points,
size_t point_count,
mln_lat_lng * out_coordinates,
mln_diagnostic * out_diagnostic )

Finds the coordinates at several screen points, as mln_map_projection_lat_lng_for_pixel() does.

Lifetimes: out_coordinates must have room for point_count coordinates.

◆ mln_map_projection_lat_lngs_for_pixels_unwrapped()

mln_status mln_map_projection_lat_lngs_for_pixels_unwrapped ( mln_map_projection projection,
const mln_screen_point * points,
size_t point_count,
mln_lat_lng * out_coordinates,
mln_diagnostic * out_diagnostic )

Finds the coordinates at several screen points, as mln_map_projection_lat_lng_for_pixel_unwrapped() does.

Lifetimes: out_coordinates must have room for point_count coordinates.

◆ mln_map_projection_meters_per_pixel_at_latitude()

mln_status mln_map_projection_meters_per_pixel_at_latitude ( mln_map_projection projection,
double latitude,
double * out_meters_per_pixel,
mln_diagnostic * out_diagnostic )

Computes how many meters one screen pixel covers at latitude, at the projection's zoom.

The result ignores the camera's pitch.

◆ mln_map_projection_pixel_for_lat_lng()

mln_status mln_map_projection_pixel_for_lat_lng ( mln_map_projection projection,
mln_lat_lng coordinate,
mln_screen_point * out_point,
mln_diagnostic * out_diagnostic )

Finds the screen point of a coordinate.

The point is in the copy of the world nearest the camera's center.

◆ mln_map_projection_pixels_for_lat_lngs()

mln_status mln_map_projection_pixels_for_lat_lngs ( mln_map_projection projection,
const mln_lat_lng * coordinates,
size_t coordinate_count,
mln_screen_point * out_points,
mln_diagnostic * out_diagnostic )

Finds the screen points of several coordinates, as mln_map_projection_pixel_for_lat_lng() does.

Lifetimes: out_points must have room for coordinate_count points.

◆ mln_map_projection_release()

void mln_map_projection_release ( mln_map_projection projection)

Releases a projection.

◆ mln_map_projection_set_camera()

mln_status mln_map_projection_set_camera ( mln_map_projection projection,
const mln_camera_options * camera,
mln_diagnostic * out_diagnostic )

Moves the projection's camera, without changing the map.

Camera fields that camera doesn't set keep their values.

◆ mln_projected_meters_for_lat_lng()

mln_status mln_projected_meters_for_lat_lng ( mln_lat_lng coordinate,
mln_projected_meters * out_meters,
mln_diagnostic * out_diagnostic )

Converts a coordinate to meters in the Web Mercator projection.