Create separated, non-continus grid with most accurate in JOSM

How to make the non-continus grid with most accurate in JOSM, as in JOSM with least effect, as the changeset seens

Such as a row detached buildings while same size, shape, and same gap distance between buildings, or detailed mapping with solar panel while most accurate (exact same location and no distorted shapes)

Probably best to ask @DressyPear4.

See

1 Like

I can use the code generated by Copilot to create fixed gap between each block, I have to test manually. Thanking excellent scripting and Copilot AI programming code generator

Code of patterned block generator, mean block with fixed gaps, suitable on solar panel or detached houses

import org.openstreetmap.josm.data.osm.*
import org.openstreetmap.josm.gui.MainApplication
import javax.swing.JOptionPane

def ds = MainApplication.getLayerManager().getEditDataSet()

// Prompt user for number of blocks
def input = JOptionPane.showInputDialog(“Number of blocks with gap:”)
if (input == null) return
int nBlocks = input.toInteger()

// Assume user selects a rectangular way
ds.getSelectedWays().each { way →
if (way.getNodes().size() == 4) {
def nodes = way.getNodes()
def xs = nodes.collect { it.lon }
def ys = nodes.collect { it.lat }
double minx = xs.min()
double maxx = xs.max()
double miny = ys.min()
double maxy = ys.max()

double dx = maxx - minx double dy = maxy - miny // Example distances: d1 = block width, d2 = gap width double d1 = dx / (nBlocks*2) // block width double d2 = d1 // gap width (can be different) double cursor = minx for (int i=0; i<nBlocks; i++) { // Block double x1 = cursor double x2 = cursor + d1 def n1 = new Node(miny, x1) def n2 = new Node(miny, x2) def n3 = new Node(maxy, x2) def n4 = new Node(maxy, x1) [n1,n2,n3,n4].each { ds.addPrimitive(it) } def newWay = new Way() [n1,n2,n3,n4,n1].each { newWay.addNode(it) } // closed newWay.put(“man_made”,“solar_panel”) ds.addPrimitive(newWay) // Advance cursor by block + gap cursor = x2 + d2 } // Ensure original way is closed if (nodes.first() != nodes.last()) { way.addNode(nodes.first()) } way.put(“landuse”,“industrial”) // whole site }

}