Version:

# Geographic Datatypes

There are different geographic data types available in pimcore: `Geopoint`, `Geobounds`, `Geopolygon` and `Geopolyline`. The country select box also belongs to the context of geo widgets, but it is rather a select input widget and therefore it is listed with the other select widgets.

## Geopoint The geopoint consists of two coordinates: latitude and longitude. In the Pimcore GUI there is the same geopoint selector widget as shown above. It allows to find coordinates for a geographic point easily. In the database the values are stored in two columns which are called latitude and longitude. Programmatically the data for this field is represented by `Pimcore\Model\DataObject\Data\Geopoint`. To set a geopoint programmatically, a new `Pimcore\Model\DataObject\Data\Geopoint` has to be instantiated:

``````\$longitude = 107.6191228;
\$latitude = -6.9174639;
\$point = new \Pimcore\Model\DataObject\Data\GeoCoordinates(\$latitude, \$longitude);
\$object->setPoint(\$point);
\$object->save();
``````

## Geobounds Geobounds represent a geographic area defined by a north eastern point and a south western point. In the pimcore GUI the input widget as shown above is available. In the database there are 4 columns with coordinates to hold the data of geobounds. Programmatically both points are `Pimcore\Model\DataObject\Data\Geopoints` and they are wrapped by the `Pimcore\Model\DataObject\Data\Geopoints` Object. The following code snippet shows how to set Geobounds:

``````use Pimcore\Model\DataObject\Data\Geobounds;
use Pimcore\Model\DataObject\Data\Geopoint;

\$northEast = new \Pimcore\Model\DataObject\Data\GeoCoordinates(150.96588134765625, -33.704920213014425);
\$southWest = new \Pimcore\Model\DataObject\Data\GeoCoordinates(150.60333251953125, -33.893217379440884);
\$object->setBounds(new Geobounds(\$northEast,\$southWest));
\$object->save();
``````

## Geopolygon The geopolygon is the third in the row of geo widgets. It allows to define a geographic area by setting an arbitrary amount of geo points. In the database these points are stored in a single column of the data type LONGTEXT in the form of a serialized array of `Pimcore\Model\DataObject\Data\Geopoints`. To set geopolygon data programmatically, an array of Geopoints has to be passed to the setter:

``````use Pimcore\Model\DataObject\Data\Geopoint;

\$data = [
new \Pimcore\Model\DataObject\Data\GeoCoordinates(-33.464671118242684, 150.54428100585938),
new \Pimcore\Model\DataObject\Data\GeoCoordinates(-33.913733814316245, 150.73654174804688),
new \Pimcore\Model\DataObject\Data\GeoCoordinates(-33.9946115848146, 151.2542724609375)
];
\$object->setPolygon(\$data);
\$object->save();
``````

## Geopolyline It allows to define a geographic path by setting an arbitrary amount of geo points. In the database these points are stored in a single column of the data type LONGTEXT in the form of a serialized array of `Pimcore\Model\DataObject\Data\Geopoints`. To set geopolygon data programmatically, an array of Geopoints has to be passed to the setter:

``````use Pimcore\Model\DataObject\Data\Geopoint;

\$data = [
new \Pimcore\Model\DataObject\Data\GeoCoordinates(-33.464671118242684, 150.54428100585938),
new \Pimcore\Model\DataObject\Data\GeoCoordinates(-33.913733814316245, 150.73654174804688),
new \Pimcore\Model\DataObject\Data\GeoCoordinates(-33.9946115848146, 151.2542724609375)
];
\$object->setPolyline(\$data);
\$object->save();
``````
{"ft_lang_label":"__label__en","ft_lang_prob":0.6858128,"math_prob":0.94894403,"size":3332,"snap":"2022-27-2022-33","text_gpt3_token_len":884,"char_repetition_ratio":0.21334134,"word_repetition_ratio":0.33604336,"special_character_ratio":0.27460983,"punctuation_ratio":0.14157706,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9921867,"pos_list":[0,1,2,3,4,5,6,7,8,9,10],"im_url_duplicate_count":[null,1,null,1,null,1,null,1,null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-07-04T21:54:46Z\",\"WARC-Record-ID\":\"<urn:uuid:c0d31cc5-0732-4615-8a55-b4d2b7628c44>\",\"Content-Length\":\"80517\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:279a6703-1a73-437e-9946-143ba9b1c482>\",\"WARC-Concurrent-To\":\"<urn:uuid:b382b69c-5da0-4677-97fc-4dab659e7c2e>\",\"WARC-IP-Address\":\"95.217.26.31\",\"WARC-Target-URI\":\"https://pimcore.com/docs/pimcore/6.9/Development_Documentation/Objects/Object_Classes/Data_Types/Geographic_Types.html\",\"WARC-Payload-Digest\":\"sha1:KMBDVQIJUKN2OJ5FD6ZETOF6K66HRUQ7\",\"WARC-Block-Digest\":\"sha1:4L6SCSV7IFSM5YFCTCPBGDNT5XRTJHWD\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-27/CC-MAIN-2022-27_segments_1656104496688.78_warc_CC-MAIN-20220704202455-20220704232455-00205.warc.gz\"}"}