Bounding box किसी भी mapping stack में सबसे simple, सबसे useful spatial primitive है। यह चार numbers हैं जो latitude और longitude space में एक rectangle describe करते हैं, और ये लगभग हर API call, GeoJSON file, और map library में दिखते हैं जिनका आप कभी use करेंगे।
यह गाइड बताती है कि bounding box क्या है, format conventions जो आपको जाननी ज़रूरी हैं, production patterns जहाँ यह earn करता है, और gotchas जो हर developer को कम से कम एक बार पकड़ते हैं।
Definition
Bounding box (bbox) वह सबसे छोटा axis-aligned rectangle है जिसमें कोई feature या points का set contained हो। "Axis-aligned" का मतलब है इसके sides latitude और longitude axes के साथ चलते हैं; rectangle rotated नहीं है। Bbox को चार numbers से describe किया जाता है: western longitude, southern latitude, eastern longitude, और northern latitude।
Paris के लिए, official municipal bbox roughly [2.224, 48.8156, 2.4699, 48.9022] है। Mainland France के लिए यह roughly [-5.142, 41.333, 9.560, 51.089] है। पूरे planet के लिए यह [-180, -90, 180, 90] है।
Bbox हमेशा दो opposite corners होते हैं। यह non-rectangular shape describe नहीं कर सकता, लेकिन किसी भी shape को wrap करने वाला rectangle describe कर सकता है, जो fast spatial filtering के लिए पर्याप्त है।
Format Question
Bbox के format conventions systems में inconsistent हैं, और यह inconsistency अधिकतर bbox bugs का source है।
GeoJSON, OGC standards, और अधिकतर modern APIs: [west, south, east, north], equivalently [minLng, minLat, maxLng, maxLat]। Longitude first, latitude second, दोनों WGS84 में।
कुछ web mapping libraries (Leaflet, Mapbox GL bounds objects): _southWest और _northEast corners के साथ LatLngBounds object। Lat first, then lng।
कई older APIs और CSV exports: [south, west, north, east] (lat first)। Spec पढ़ें।
Tile services और WMS: projection के units में bbox (Web Mercator metres, lat/lng नहीं) जब tile EPSG:3857 में हो।
Defensive rule: अपने code में कभी bare 4-element array use न करें। इसे named fields के साथ typed object में wrap करें ({ west, south, east, north }) ताकि order explicit हो। API boundaries पर convert करें।
Bounding Boxes कहाँ अपना काम दिखाते हैं
Bbox सबसे fast possible spatial filter है। तीन classic uses:
Map को feature पर fit करना। जब user किसी search result पर land करता है, आप map.fitBounds(bbox) call करते हैं और map feature show करने के लिए zoom और pan करता है। हर modern map library में यह primitive है।
API queries को area से filter करना। Database engines और search APIs bboxes को very efficiently index करते हैं। "इस viewport में सभी places show करो" जैसी query visible bbox server को send करती है, जो matching records return करने के लिए spatial index use करता है। यह viewport-based search की foundation है।
Autocomplete और geocoding bias करना। User का current map bbox viewport bias के रूप में pass करें। Geocoder bbox के भीतर results को heavily weight करता है, इसलिए New York viewport के भीतर "Liberty" type करना किसी दूसरे Liberty से पहले Statue of Liberty return करता है।
एक चौथा, कम obvious use: bboxes vector tile system की bookkeeping unit हैं। हर tile एक known zoom पर एक known bbox cover करती है, और renderer उन्हें visible map में composite करता है।
API क्या Return करती है
अधिकतर geocoding APIs हर match के साथ bbox return करती हैं, क्योंकि यह दोनों matched feature की size बताता है (country bbox huge है, building bbox tiny है) और map fit कैसे करें। "France" के लिए geocoding response national-scale bbox return करता है; "10 Downing Street" के लिए building-scale bbox।
Returned bbox की size को precision पर sanity check के रूप में use कर सकते हैं। वह query जो "country" precision पर match करे लेकिन building-sized bbox return करे suspicious है।
Bounding Boxes जो Antimeridian Cross करते हैं
एक subtle gotcha: वह bbox जो 180-degree antimeridian cross करता है (जैसे Russia, Pacific, Fiji के लिए) west < east के रूप में describe नहीं किया जा सकता क्योंकि यह wrap around करता है। Conventions vary करते हैं:
- कुछ systems ऐसे bbox को दो pieces में split करते हैं, antimeridian के हर side के लिए एक।
- कुछ systems
west > eastallow करते हैं और इसे "wrap around" interpret करते हैं। - GeoJSON wrap-around allow करता है लेकिन interoperability के लिए splitting recommend करता है।
अधिकतर European या single-country use cases के लिए यह कभी नहीं आता। अगर आप global product बनाते हैं (airline routes, shipping, fisheries), antimeridian case explicitly test करें।
Bounding Boxes बनाम Polygons
Bbox एक rectangle है। Real feature rarely rectangular होती है। France का bbox Atlantic Ocean और Spain के parts include करता है। Manhattan का bbox New Jersey और Queens के parts include करता है।
जब rectangle approximation पर्याप्त हो (map fit करना, fast pre-filtering), bbox सही tool है। जब आपको जानना हो कि point वास्तव में feature के अंदर है, तो real boundary geometry के against point-in-polygon math चाहिए। एक common production pattern: पहले bbox से filter करें (fast, indexable, 99% records eliminate करता है), फिर survivors पर point-in-polygon run करें (slow but accurate)। यह two-stage approach है जिससे अधिकतर spatial databases काम करती हैं।
Computer Vision में Bounding Boxes
Object detection, robotics, या 3D rendering में "oriented bounding box" mention देख सकते हैं। यह अलग concept है: OBB feature को axis-aligned box से ज़्यादा tightly fit करने के लिए rotated होता है। Geospatial work में, axis-aligned bboxes standard हैं क्योंकि ये cleanly index होते हैं, tile grid में slot होते हैं, और overlap test करना trivial है।
MapAtlas Bounding Boxes कैसे Use करता है
Geocoding API और Search API के हर result के साथ WGS84 longitude/latitude order में bbox field return होती है, exactly वह format जो GeoJSON और modern map libraries expect करती हैं। Geocoding को viewport तक bias करने के लिए boundary.rect.* parameter pass कर सकते हैं, और Isochrone API अपने travel-time polygons wrapping bbox के साथ return करती है ताकि आप खुद compute किए बिना map fit कर सकें।
GeoJSON और bboxes larger spatial data picture में कैसे fit होते हैं इसके hands-on intro के लिए, What Is GeoJSON और What Is a Geocode देखें।
अक्सर पूछे जाने वाले प्रश्न
Bounding box क्या होता है?
Bounding box (अक्सर bbox छोटा किया जाता है) वह सबसे छोटा axis-aligned rectangle है जिसमें कोई geographic feature या points का set contained हो। इसे चार numbers से describe किया जाता है: minimum और maximum longitude और minimum और maximum latitude। Bounding boxes mapping में हर जगह use होते हैं: map को feature पर fit करने के लिए, area से database queries filter करने के लिए, tile की extent define करने के लिए, और geocoding results को किसी region तक bias करने के लिए।
Bounding box का standard format क्या है?
GeoJSON और अधिकतर modern APIs [west, south, east, north] order use करते हैं, जिसे [minLng, minLat, maxLng, maxLat] भी लिखा जाता है। यही वह format है जिसे आपको default करना चाहिए। कुछ older APIs और CSV exports [south, west, north, east] (lat first) use करते हैं। हमेशा specific API या format के docs चेक करें। सबसे आम गलती lat/lng order mix करना है।
Bounding box और oriented bounding box में क्या अंतर है?
Regular bounding box axis-aligned है: इसके sides latitude और longitude axes के साथ चलते हैं। Oriented bounding box (OBB, computer vision और game engines में आम) feature को और tightly fit करने के लिए rotated होता है। Geospatial work में, axis-aligned bboxes standard हैं क्योंकि ये spatial databases में cleanly index होते हैं, tile grid में slot होते हैं, और overlap के लिए trivially testable हैं।
Geocoding API filter करने के लिए bounding box कैसे use करें?
Bbox को viewport bias parameter के रूप में pass करें। MapAtlas Geocoding API में आप `boundary.rect.min_lon`, `boundary.rect.min_lat`, `boundary.rect.max_lon`, `boundary.rect.max_lat` send करते हैं, और geocoder उस area के भीतर के results को बाहर के results से higher rank करता है। यह map के अंदर autocomplete के लिए essential है: जैसे user pan करता है, आप bbox update करते हैं ताकि suggestions match करें जो वे देख रहे हैं।

