voxcity.geoprocessor.draw.rectangle =================================== .. py:module:: voxcity.geoprocessor.draw.rectangle .. autoapi-nested-parse:: Interactive rectangle drawing and rotation utilities for geographic maps. Provides functions for: - Drawing rectangles on interactive ipyleaflet maps - Rotating rectangles with proper coordinate transformations - City-centered map initialization with rectangle drawing - Fixed-dimension rectangle creation from center points Functions --------- .. autoapisummary:: voxcity.geoprocessor.draw.rectangle.rotate_rectangle voxcity.geoprocessor.draw.rectangle.draw_rectangle_map voxcity.geoprocessor.draw.rectangle.draw_rectangle_map_cityname voxcity.geoprocessor.draw.rectangle.center_location_map_cityname voxcity.geoprocessor.draw.rectangle.rectangle_map voxcity.geoprocessor.draw.rectangle.create_rectangle_map Module Contents --------------- .. py:function:: rotate_rectangle(m, rectangle_vertices, angle) Project rectangle to Mercator, rotate, and re-project to lat-lon coordinates. The rotation is performed around the rectangle's centroid using a standard 2D rotation matrix in Web Mercator space for accurate distance preservation. :param m: Map object to draw the rotated rectangle on. :type m: ipyleaflet.Map :param rectangle_vertices: List of (lon, lat) tuples defining the rectangle. :type rectangle_vertices: list :param angle: Rotation angle in degrees (positive = counter-clockwise). :type angle: float :returns: Rotated (lon, lat) tuples, or None if no vertices provided. :rtype: list .. py:function:: draw_rectangle_map(center=(40, -100), zoom=4) Create an interactive map for drawing rectangles with two modes. - **Aligned** mode: click two opposite corners to draw an axis-aligned rectangle. - **Rotated** mode: click 3 points to draw a rotated rectangle. Drawing starts immediately when a mode button is selected. :param center: Center coordinates (lat, lon). Defaults to (40, -100). :type center: tuple :param zoom: Initial zoom level. Defaults to 4. :type zoom: int :returns: (ipywidgets.VBox, list that will be populated with (lon, lat) vertices) :rtype: tuple .. py:function:: draw_rectangle_map_cityname(cityname, zoom=15) Create an interactive map centered on a specified city for drawing rectangles. Two modes are available via toggle buttons: - **Aligned**: click two opposite corners (axis-aligned rectangle). - **Rotated**: click 3 points to draw a rotated rectangle. :param cityname: Name of the city (e.g. "Tokyo, Japan"). :type cityname: str :param zoom: Initial zoom level. Defaults to 15. :type zoom: int :returns: (ipywidgets.VBox, list that will be populated with (lon, lat) vertices) :rtype: tuple .. py:function:: center_location_map_cityname(cityname, east_west_length, north_south_length, zoom=15, rotation_angle=0) Create a map centered on a city where clicking creates a rectangle of specified dimensions. After placing a center point, an interactive rotation slider appears so the rectangle can be rotated on the map in real time. :param cityname: Name of the city. :type cityname: str :param east_west_length: Width of the rectangle in meters. :type east_west_length: float :param north_south_length: Height of the rectangle in meters. :type north_south_length: float :param zoom: Initial zoom level. Defaults to 15. :type zoom: int :param rotation_angle: Initial rotation angle in degrees (positive = counter-clockwise). Defaults to 0. :type rotation_angle: float :returns: (widget, list that will be populated with (lon, lat) vertices) *widget* is an ipywidgets VBox containing the map and a rotation slider. Display it with ``display(widget)`` or as the last expression in a notebook cell. :rtype: tuple .. py:function:: rectangle_map(center=(40, -100), zoom=15, width=500, height=500, cityname='') Create an interactive map with a side panel for drawing rectangles. Three drawing modes are provided via the panel: - **Aligned**: click two opposite corners for an axis-aligned rectangle. - **Rotated**: click 3 points to draw a rotated rectangle. - **Fixed**: click a center point to place a rectangle with the specified *width* (east-west) and *height* (north-south), then adjust the rotation angle with a slider. The panel includes a city-name field that re-centres the map on submission. :param center: Map center as (lat, lon). Defaults to (40, -100). :type center: tuple :param zoom: Initial zoom level. Defaults to 15. :type zoom: int :param width: Initial east-west length in metres (for Fixed mode). :type width: float :param height: Initial north-south length in metres (for Fixed mode). :type height: float :param cityname: Pre-filled city name for the location field. :type cityname: str :returns: (ipywidgets.VBox, list that will be populated with (lon, lat) vertices) :rtype: tuple .. py:function:: create_rectangle_map(cityname=None, zoom=15, width=500, height=500) Create an interactive rectangle-drawing map with a side panel. Combines aligned / rotated drawing and fixed-dimension placement into a single map. If *cityname* is provided the map is centred on that city and the location field is pre-filled; otherwise a world-level view is shown and the user can type a city name into the panel. :param cityname: Name of the city (e.g. ``"Tokyo"``). :type cityname: str, optional :param zoom: Initial zoom level. Defaults to 15. :type zoom: int :param width: Initial east-west length in metres (for Fixed mode). :type width: float :param height: Initial north-south length in metres (for Fixed mode). :type height: float :returns: (ipywidgets.VBox, list that will be populated with (lon, lat) vertices in SW → NW → NE → SE order) :rtype: tuple