Skip to content

Commit 88e46f5

Browse files
Adding ability to process coordinates before drawing. Adding the ability to Placemark and all subclasses
1 parent f93c50a commit 88e46f5

File tree

6 files changed

+23
-14
lines changed

6 files changed

+23
-14
lines changed

src/main/java/com/codingpupper3033/codebtekml/events/KeyPressed.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.codingpupper3033.codebtekml.events;
22

33
import com.codingpupper3033.codebtekml.KeyInit;
4-
import com.codingpupper3033.codebtekml.helpers.map.altitude.AltitudeProcessor;
4+
import com.codingpupper3033.codebtekml.gui.screens.GuiDrawKML;
55
import net.minecraft.client.Minecraft;
66
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
77
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
@@ -15,8 +15,7 @@ public class KeyPressed {
1515
public void clientTick(ClientTickEvent event) {
1616
if (Minecraft.getMinecraft().currentScreen == null) { // Keystrokes that only work on the default game menu
1717
// Open KML Menu
18-
//if (KeyInit.openKMLMenuKeybind.isPressed()) Minecraft.getMinecraft().displayGuiScreen(new GuiDrawKML(null));
19-
if (KeyInit.openKMLMenuKeybind.isPressed()) AltitudeProcessor.defaultProcessor.processCoordinateQueue();
18+
if (KeyInit.openKMLMenuKeybind.isPressed()) Minecraft.getMinecraft().displayGuiScreen(new GuiDrawKML(null));
2019
}
2120
}
2221
}

src/main/java/com/codingpupper3033/codebtekml/helpers/map/Placemark.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ public Placemark(Element element) {
1616

1717
}
1818

19-
//public abstract Coordinate[] getCoordinates();
19+
/**
20+
* Gets all coordinates that this placemark uses, so we can pre-process them
21+
* @return all the Coordinates in this placemark
22+
*/
23+
public abstract Coordinate[] getCoordinates();
2024

2125
/**
2226
* Should draw the placemark into the game

src/main/java/com/codingpupper3033/codebtekml/helpers/map/altitude/AltitudeProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class AltitudeProcessor {
2828
/**
2929
* List of coordinates to process
3030
*/
31-
public Queue<Coordinate> coordinateProcessorQueue = new LinkedList<>();
31+
private Queue<Coordinate> coordinateProcessorQueue = new LinkedList<>();
3232

3333
/**
3434
* Default altitude method. Should not be used.

src/main/java/com/codingpupper3033/codebtekml/helpers/map/altitude/OpenElevationAltitudeProcessor.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,15 @@ public double[] getGroundLevels(Coordinate[] coordinates) throws IOException {
9696
public boolean processCoordinateQueue() {
9797
super.processCoordinateQueue();
9898

99-
for (int i = 0; i <17; i++) {
100-
coordinateProcessorQueue.add(new Coordinate(42.7264177662084, -73.67230722692297,0,AltitudeMode.RELATIVE_TO_GROUND));
101-
}
102-
103-
while (!coordinateProcessorQueue.isEmpty()) { // Keep working until all out
104-
Coordinate[] setOfLocationsToProcess = new Coordinate[Math.min(MAX_COORDINATES_PER_REQUEST,coordinateProcessorQueue.size())]; // Make it only as big as needed
99+
while (!getCoordinateProcessorQueue().isEmpty()) { // Keep working until all out
100+
Coordinate[] setOfLocationsToProcess = new Coordinate[Math.min(MAX_COORDINATES_PER_REQUEST,getCoordinateProcessorQueue().size())]; // Make it only as big as needed
105101
int i = 0;
106-
while (!coordinateProcessorQueue.isEmpty() && i < setOfLocationsToProcess.length) { // Only do the max size at a time
107-
setOfLocationsToProcess[i] = coordinateProcessorQueue.poll();
102+
while (!getCoordinateProcessorQueue().isEmpty() && i < setOfLocationsToProcess.length) { // Only do the max size at a time
103+
setOfLocationsToProcess[i] = getCoordinateProcessorQueue().poll();
108104
i++;
109105
}
110106

111-
// Process them
107+
// Process this set
112108
try {
113109
double[] groundLevels = getGroundLevels(setOfLocationsToProcess);
114110

src/main/java/com/codingpupper3033/codebtekml/helpers/map/placemark/LineString.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ public LineString(Element element) {
2121
coordinates = KMLParser.getElementCoordinates(element);
2222
}
2323

24+
@Override
25+
public Coordinate[] getCoordinates() {
26+
return coordinates;
27+
}
28+
2429
@Override
2530
public void draw(String blockName) {
2631
for (int i = 1; i < coordinates.length; i++) {

src/main/java/com/codingpupper3033/codebtekml/helpers/map/placemark/Point.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public Point(Element element) {
1919
coordinate = KMLParser.getElementCoordinates(element)[0]; // Only one coordinate as it is a point
2020
}
2121

22+
@Override
23+
public Coordinate[] getCoordinates() {
24+
return new Coordinate[]{coordinate};
25+
}
26+
2227
@Override
2328
public void draw(String blockName) {
2429
MinecraftCommands.set(coordinate, blockName); // Use World Edit set command as a point will just be a block

0 commit comments

Comments
 (0)