Home Java javaTutorial Geo Viewer in IntelliJ Idea is cool

Geo Viewer in IntelliJ Idea is cool

Oct 23, 2024 am 01:02 AM

Hello old friend

Thanks to Poznań Java User Group randomly selecting me during a meetup to get a JetBrains IntelliJ Idea Ultimate license, I started using it daily. It's not entirely new software for me. I've been using Android Studio for almost a decade now, occasionally working on side projects in the Community Edition of IntelliJ. Recently at work, I've been using VS Code and NeoVim. Quite a different IDE philosophy with the latter.

I happen to work on the backend currently, and IntelliJ is an absolute beast with built-in tools for everything you can imagine.

Next to the usual language support for TypeScript, SQL, and build configs, there are nice database tools. Data display is similar to an Excel spreadsheet, allows filtering, can generate DDL code, draw diagrams, etc. Nothing too special; other tools make this happen.

But this is just inside the IDE, so it is easy to reach without changing the context.

Geo Viewer

I noticed the Geo Viewer tool by accident.

Geo Viewer in IntelliJ Idea is cool

I'm dealing with some geographic data, like areas and points. Geo Viewer works out of the box. No plugins or configs are required. At least for Postgres with Postgis setup.

It may seem like unnecessary visuals, but it's actually useful for debugging. Think about having a query that returns points from one table, inside the area defined in another one. How great it is to see the result on the actual map.

Let's put it to work

I used ChatGPT to generate data for Poland's voivodships. It's not entirely bad... They are kinda in the right places, just way too small.

Data for city locations is OK.

Geo Viewer in IntelliJ Idea is cool

To visualize cities and areas on a single Geo View, I used a simple SQL view. I haven't touched SQL since university, so this is also a fun experience :D

-- Enable PostGIS extension if not already enabled  
CREATE EXTENSION IF NOT EXISTS postgis;  

-- Create vovoidships table  
CREATE TABLE vovoidships (  
    id SERIAL PRIMARY KEY,  
    name VARCHAR(255) NOT NULL,  
    bounds GEOMETRY NOT NULL  
);  

-- Create cities table  
CREATE TABLE cities (  
    id SERIAL PRIMARY KEY,  
    name VARCHAR(255) NOT NULL,  
    coordinates GEOMETRY NOT NULL  
);  

-- Insert Polish voivodeship capitals into cities table  
INSERT INTO cities (name, coordinates) VALUES  
    ('Warsaw', ST_SetSRID(ST_MakePoint(21.0122, 52.2297), 4326)),  -- Mazowieckie  
    ('Kraków', ST_SetSRID(ST_MakePoint(19.9449, 50.0647), 4326)),  -- Małopolskie  
    ('Łódź', ST_SetSRID(ST_MakePoint(19.456, 51.7592), 4326)),     -- Łódzkie  
    ('Wrocław', ST_SetSRID(ST_MakePoint(17.0385, 51.1079), 4326)), -- Dolnośląskie  
    ('Poznań', ST_SetSRID(ST_MakePoint(16.9286, 52.4064), 4326)),  -- Wielkopolskie  
    ('Gdańsk', ST_SetSRID(ST_MakePoint(18.646, 54.352), 4326)),    -- Pomorskie  
    ('Szczecin', ST_SetSRID(ST_MakePoint(14.5528, 53.4289), 4326)),-- Zachodniopomorskie  
    ('Bydgoszcz', ST_SetSRID(ST_MakePoint(18.0076, 53.1235), 4326)), -- Kujawsko-Pomorskie  
    ('Lublin', ST_SetSRID(ST_MakePoint(22.5686, 51.2465), 4326)),   -- Lubusz  
    ('Białystok', ST_SetSRID(ST_MakePoint(23.1641, 53.1325), 4326)), -- Podlaskie  
    ('Katowice', ST_SetSRID(ST_MakePoint(19.039, 50.2583), 4326)), -- Śląskie  
    ('Opole', ST_SetSRID(ST_MakePoint(17.9213, 50.6644), 4326)),    -- Opolskie  
    ('Rzeszów', ST_SetSRID(ST_MakePoint(21.9981, 50.0415), 4326)),  -- Podkarpackie  
    ('Gorzów Wlkp.', ST_SetSRID(ST_MakePoint(15.2299, 52.7387), 4326)), -- Lubusz  
    ('Zielona Góra', ST_SetSRID(ST_MakePoint(15.5061, 51.9353), 4326)); -- Lubusz  

-- Insert Polish voivodeships into vovoidships table with corrected boundaries  
INSERT INTO vovoidships (name, bounds) VALUES  
    ('Mazowieckie', ST_SetSRID(ST_GeomFromText('POLYGON((20.5937 52.4304, 20.7031 52.2398, 21.0994 52.1985, 21.4855 52.2738, 21.7426 52.5456, 21.4822 52.6935, 20.8778 52.6281, 20.5937 52.4304))'), 4326)),  
    ('Małopolskie', ST_SetSRID(ST_GeomFromText('POLYGON((19.0013 49.6121, 19.3004 49.2235, 19.8534 49.1386, 20.1253 49.2158, 20.3469 49.7248, 20.1154 49.9501, 19.0013 49.6121))'), 4326)),  
    ('Łódzkie', ST_SetSRID(ST_GeomFromText('POLYGON((18.9224 51.6847, 19.5032 51.5472, 19.7415 51.7594, 19.6886 52.0549, 19.1579 52.0201, 18.9224 51.6847))'), 4326)),  
    ('Dolnośląskie', ST_SetSRID(ST_GeomFromText('POLYGON((16.2795 50.1585, 16.6575 49.9253, 17.1573 49.8861, 17.3046 50.3278, 17.1566 50.4869, 16.6676 50.5302, 16.2795 50.1585))'), 4326)),  
    ('Wielkopolskie', ST_SetSRID(ST_GeomFromText('POLYGON((16.4570 52.0254, 16.9745 51.8472, 17.4446 51.8598, 17.8387 52.0295, 17.5519 52.3232, 16.4570 52.0254))'), 4326)),  
    ('Pomorskie', ST_SetSRID(ST_GeomFromText('POLYGON((17.9927 54.0531, 18.7247 54.0065, 18.7840 53.8160, 18.5911 53.7163, 17.9927 54.0531))'), 4326)),  
    ('Zachodniopomorskie', ST_SetSRID(ST_GeomFromText('POLYGON((14.2102 53.4019, 14.8960 53.3481, 15.0853 53.3305, 15.0006 53.0747, 14.2102 53.4019))'), 4326)),  
    ('Kujawsko-Pomorskie', ST_SetSRID(ST_GeomFromText('POLYGON((17.8260 53.0401, 18.2550 52.9635, 19.1827 52.9581, 19.1902 53.1355, 18.0730 53.1274, 17.8260 53.0401))'), 4326)),  
    ('Lubuskie', ST_SetSRID(ST_GeomFromText('POLYGON((14.3215 52.2755, 14.7083 52.2985, 15.0293 52.4335, 15.0641 52.5437, 14.3215 52.2755))'), 4326)),  
    ('Podlaskie', ST_SetSRID(ST_GeomFromText('POLYGON((22.7210 53.6851, 22.9785 53.4699, 23.4987 53.4057, 23.7810 53.6431, 22.7210 53.6851))'), 4326)),  
    ('Śląskie', ST_SetSRID(ST_GeomFromText('POLYGON((18.6704 50.1671, 19.0423 50.1492, 19.3875 50.2675, 19.5927 50.2046, 19.1676 50.0395, 18.6704 50.1671))'), 4326)),  
    ('Opolskie', ST_SetSRID(ST_GeomFromText('POLYGON((17.2070 50.5458, 17.4982 50.3454, 17.7513 50.2998, 17.8897 50.5008, 17.2070 50.5458))'), 4326)),  
    ('Podkarpackie', ST_SetSRID(ST_GeomFromText('POLYGON((21.1791 49.8919, 21.4867 49.8395, 21.9074 49.7579, 22.0595 49.8491, 21.1791 49.8919))'), 4326));  

CREATE VIEW CombinedVoivodeshipsCitiesView AS  
SELECT  
    'Voivodeship' AS type,  
    v.id AS id,  
    v.name AS name,  
    NULL AS latitude,  
    NULL AS longitude,  
    v.bounds AS geometry  
FROM vovoidships v  

UNION ALL  

SELECT  
    'City' AS type,  
    c.id AS id,  
    c.name AS name,  
    ST_Y(c.coordinates) AS latitude,  
    ST_X(c.coordinates) AS longitude,  
    c.coordinates AS geometry  
FROM cities c;
Copy after login

Influenced by Kacper Koza presentation on last JUGtoberfest I started using more IntelliJ shortcuts. And turned off tabs. So far so good, my mouse is getting some rest.

What's your latest discovery in the tools you use?

The above is the detailed content of Geo Viewer in IntelliJ Idea is cool. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How does Java's classloading mechanism work, including different classloaders and their delegation models? How does Java's classloading mechanism work, including different classloaders and their delegation models? Mar 17, 2025 pm 05:35 PM

Java's classloading involves loading, linking, and initializing classes using a hierarchical system with Bootstrap, Extension, and Application classloaders. The parent delegation model ensures core classes are loaded first, affecting custom class loa

How do I implement multi-level caching in Java applications using libraries like Caffeine or Guava Cache? How do I implement multi-level caching in Java applications using libraries like Caffeine or Guava Cache? Mar 17, 2025 pm 05:44 PM

The article discusses implementing multi-level caching in Java using Caffeine and Guava Cache to enhance application performance. It covers setup, integration, and performance benefits, along with configuration and eviction policy management best pra

How can I use JPA (Java Persistence API) for object-relational mapping with advanced features like caching and lazy loading? How can I use JPA (Java Persistence API) for object-relational mapping with advanced features like caching and lazy loading? Mar 17, 2025 pm 05:43 PM

The article discusses using JPA for object-relational mapping with advanced features like caching and lazy loading. It covers setup, entity mapping, and best practices for optimizing performance while highlighting potential pitfalls.[159 characters]

How do I use Maven or Gradle for advanced Java project management, build automation, and dependency resolution? How do I use Maven or Gradle for advanced Java project management, build automation, and dependency resolution? Mar 17, 2025 pm 05:46 PM

The article discusses using Maven and Gradle for Java project management, build automation, and dependency resolution, comparing their approaches and optimization strategies.

How do I create and use custom Java libraries (JAR files) with proper versioning and dependency management? How do I create and use custom Java libraries (JAR files) with proper versioning and dependency management? Mar 17, 2025 pm 05:45 PM

The article discusses creating and using custom Java libraries (JAR files) with proper versioning and dependency management, using tools like Maven and Gradle.

See all articles