问:
Errors loading Blender Wavefront Model
Hopefully someone can help me. I am trying to load a model I made in Blender into my JOGL program. I was able to manual models working and set up my window but there is something wrong with parsing the .obj wavefront file. No errors in my code that I can see, the ImportedModel class came from a textbook.

Here is the code:

```<code>import com.jogamp.common.nio.Buffers;
import com.jogamp.opengl.*;
import com.jogamp.opengl.awt.GLCanvas;
import com.jogamp.opengl.util.Animator;
import org.joml.Matrix4f;
import org.joml.Vector2f;
import org.joml.Vector3f;

import javax.swing.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List;

import static com.jogamp.opengl.GL.*;

public class WalkingTour extends JFrame implements GLEventListener, KeyListener {

private static final int windowWidth = 800, windowHeight = 600;
private static final String windowTitle = "Walking Tour";
private static final String vertexShaderFile = "src/walkingtour-vertex.glsl",
        fragmentShaderFile = "src/walkingtour-fragment.glsl";
private final GLCanvas glCanvas;
private int renderingProgram;
private final int[] vao = new int[1];
private final int[] vbo = new int[6];
private final FloatBuffer values = Buffers.newDirectFloatBuffer(16);
private final Matrix4f pMat = new Matrix4f();  // perspective matrix
private final Matrix4f vMat = new Matrix4f();  // view matrix
private final Matrix4f mMat = new Matrix4f();  // model matrix
private final Matrix4f mvMat = new Matrix4f(); // model-view matrix
private int gTexture;
private ImportedModel myModel;
private int numObjVertices;

private boolean keyPressedForward = false,
        keyPressedBackward = false,
        keyPressedMoveRight = false,
        keyPressedMoveLeft = false,
        keyPressedTurnRight = false,
        keyPressedTurnLeft = false,
        keyPressedSpace = false,
        keyPressedControl = false,
        keyPressedShift = false;
private final ArrayList<Float> vertexValues = new ArrayList<>();
private final ArrayList<Float> stVals = new ArrayList<>();
private final ArrayList<Float> normalValues = new ArrayList<>();

private final ArrayList<Float> triangleVerts = new ArrayList<>();
private final ArrayList<Float> textureCoordinates = new ArrayList<>();
private final ArrayList<Float> normals = new ArrayList<>();

private List<float[]> vertices = new ArrayList<float[]>();
private List<int[]> faces =new ArrayList<int[]>();

public WalkingTour() {
    setTitle(windowTitle);
    setSize(windowWidth, windowHeight);
    glCanvas = new GLCanvas(new GLCapabilities(GLProfile.getMaxProgrammableCore(true)));
    glCanvas.addGLEventListener(this);
    this.add(glCanvas);
    this.setVisible(true);
    Animator animator = new Animator(glCanvas);
    animator.start();
}

public static void main(String[] args) {
    new WalkingTour();
}

@Override
public void init(GLAutoDrawable glAutoDrawable) {

    myModel = new ImportedModel("hwk5Model.obj");

    GL4 gl = (GL4) GLContext.getCurrentGL();

    numObjVertices = myModel.getNumVertices();
    Vector3f[ ] vertices = myModel.getVertices();
    Vector2f[ ] texCoords = myModel.getTexCoords();
    Vector3f[ ] normals = myModel.getNormals();
    float[ ] pvalues = new float[numObjVertices*3];        // vertex positions
    float[ ] tvalues = new float[numObjVertices*2];        // texture coordinates
    float[ ] nvalues = new float[numObjVertices*3];        // normal vectors

    for (int i=0; i<numObjVertices; i++)
    {   pvalues[i*3]   = (float) (vertices[i]).x();
        pvalues[i*3+1]     = (float) (vertices[i]).y();
        pvalues[i*3+2]  = (float) (vertices[i]).z();
        tvalues[i*2]    = (float) (texCoords[i]).x();
        tvalues[i*2+1]  = (float) (texCoords[i]).y();
        nvalues[i*3]    = (float) (normals[i]).x();
        nvalues[i*3+1]  = (float) (normals[i]).y();
        nvalues[i*3+2]  = (float) (normals[i]).z();
    }

    // VBO for vertex locations
    gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[2]);
    FloatBuffer vertBuf = Buffers.newDirectFloatBuffer(pvalues);
    gl.glBufferData(GL_ARRAY_BUFFER, vertBuf.limit()*4, vertBuf, GL_STATIC_DRAW);
// VBO for texture coordinates
    gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[3]);
    FloatBuffer texBuf = Buffers.newDirectFloatBuffer(tvalues);
    gl.glBufferData(GL_ARRAY_BUFFER, texBuf.limit()*4, texBuf, GL_STATIC_DRAW);
// VBO for normal vectors
    gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[4]);
    FloatBuffer norBuf = Buffers.newDirectFloatBuffer(nvalues);
    gl.glBufferData(GL_ARRAY_BUFFER, norBuf.limit()*4,norBuf, GL_STATIC_DRAW);

    renderingProgram = Utils.createShaderProgram(vertexShaderFile, fragmentShaderFile);
    gTexture = Utils.loadTexture("groundTexture.jpeg");
    gl.glActiveTexture(GL_TEXTURE0);
    gl.glBindTexture(GL_TEXTURE_2D, gTexture);

    float[] floor = {
            -2000.0f, -50.0f, -2000.0f, -2000.0f, -50.0f, 2000.0f, 2000.0f, -50.0f, 2000.0f,
            -2000.0f, -50.0f, -2000.0f, 2000.0f, -50.0f, -2000.0f, 2000.0f, -50.0f, 2000.0f,
    };

    gl.glGenVertexArrays(vao.length, vao, 0);
    gl.glBindVertexArray(vao[0]);
    gl.glGenBuffers(vbo.length, vbo, 0);

    FloatBuffer corBuf = Buffers.newDirectFloatBuffer(floor);
    gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
    gl.glBufferData(GL_ARRAY_BUFFER, corBuf.limit() * 4L, corBuf, GL_STATIC_DRAW);

    float[] textureCoords = {
            0f, 1f, 0f, 0f, 1f, 0f,
            0f, 1f, 1f, 1f, 1f, 0f
    };

    FloatBuffer textureBuffer = Buffers.newDirectFloatBuffer(textureCoords);
    gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[1]);
    gl.glBufferData(GL_ARRAY_BUFFER, textureBuffer.limit() * 4L, textureBuffer, GL_STATIC_DRAW);

    this.addKeyListener(this);
}

@Override
public void dispose(GLAutoDrawable glAutoDrawable) {
    this.removeKeyListener(this);
}

@Override
public void display(GLAutoDrawable glAutoDrawable) {
    GL4 gl = (GL4) GLContext.getCurrentGL();

    gl.glClear(GL_COLOR_BUFFER_BIT);
    gl.glClear(GL_DEPTH_BUFFER_BIT);
    gl.glUseProgram(renderingProgram);

    int mvLoc = gl.glGetUniformLocation(renderingProgram, "mv_matrix");
    int pLoc = gl.glGetUniformLocation(renderingProgram, "p_matrix");

    float aspect = (float) glCanvas.getWidth() / (float) glCanvas.getHeight();
    pMat.identity().setPerspective((float) Math.toRadians(60.0f), aspect, 0.1f, 5000.0f);
    gl.glUniformMatrix4fv(pLoc, 1, false, pMat.get(values));

    vMat.translate(0f,0f,0f);

    mvMat.identity();
    mvMat.mul(vMat);
    mvMat.mul(mMat);

    gl.glUniformMatrix4fv(mvLoc, 1, false, mvMat.get(values));
    gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
    gl.glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0);
    gl.glEnableVertexAttribArray(0);
    gl.glEnable(GL_DEPTH_TEST);
    gl.glDepthFunc(GL_LEQUAL);

    gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[1]);
    gl.glVertexAttribPointer(1, 2, GL_FLOAT, false, 0, 0);
    gl.glEnableVertexAttribArray(1);

    gl.glBindTexture(GL_TEXTURE_2D, gTexture);
    gl.glDrawArrays(GL_TRIANGLES, 0, 6);
    gl.glDrawArrays(GL_TRIANGLES, 0, myModel.getNumVertices());

    if (keyPressedForward) {
        vMat.translateLocal(0f, 0f, 0.1f);
    }
    if (keyPressedBackward) {
        vMat.translateLocal(0f,0f,-0.1f);
    }
    if (keyPressedMoveLeft) {
        vMat.translateLocal(0.1f,0f,0f);
    }
    if (keyPressedMoveRight) {
        vMat.translateLocal(-0.1f,0f,0f);
    }
    if (keyPressedTurnLeft) {
        vMat.rotateLocalY(-0.001f);
    }
    if (keyPressedTurnRight) {
        vMat.rotateLocalY(0.001f);
    }
    if (keyPressedSpace) {
        vMat.translateLocal(0f,-0.1f,0f);
    }
    if (keyPressedControl) {
        vMat.translateLocal(0f,0.1f,0f);
    }
    if (keyPressedForward && keyPressedShift){
        vMat.translateLocal(0f,0f,0.2f);
    }

}

@Override
public void reshape(GLAutoDrawable glAutoDrawable, int i, int i1, int i2, int i3) {

}

@Override
public void keyTyped(KeyEvent e) {
    //do nothing
}

@Override
public void keyPressed(KeyEvent e) {
    int keyCode = e.getKeyCode();
    if (keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_W) {
        // Move camera forward
        keyPressedForward = true;
    } else if (keyCode == KeyEvent.VK_DOWN || keyCode == KeyEvent.VK_S) {
        // Move camera backward
        keyPressedBackward = true;
    } else if (keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_A) {
        // Move camera to the left
        keyPressedMoveLeft = true;
    } else if (keyCode == KeyEvent.VK_RIGHT || keyCode == KeyEvent.VK_D) {
        // Move camera to the right
        keyPressedMoveRight = true;
    } else if (keyCode == KeyEvent.VK_HOME || keyCode == KeyEvent.VK_Q) {
        // Turn camera to the left
        keyPressedTurnLeft = true;
    } else if (keyCode == KeyEvent.VK_PAGE_UP || keyCode == KeyEvent.VK_E) {
        // Turn camera to the right
        keyPressedTurnRight = true;
    } else if (keyCode == KeyEvent.VK_SPACE) {
        // Move camera up
        keyPressedSpace = true;
    } else if (keyCode == KeyEvent.VK_CONTROL) {
        // Move camera down
        keyPressedControl = true;
    } else if (keyCode == KeyEvent.VK_SHIFT) {
        //hold shift to "sprint"
        //can only sprint while forward buttons are pressed
        keyPressedShift = true;
    }
}

@Override
public void keyReleased(KeyEvent e) {
    int keyCode = e.getKeyCode();
        if (keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_W) {
            // Move camera forward
            keyPressedForward = false;
        } else if (keyCode == KeyEvent.VK_DOWN || keyCode == KeyEvent.VK_S) {
            // Move camera backward
            keyPressedBackward = false;
        } else if (keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_A) {
            // Move camera to the left
            keyPressedMoveLeft = false;
        } else if (keyCode == KeyEvent.VK_RIGHT || keyCode == KeyEvent.VK_D) {
            // Move camera to the right
            keyPressedMoveRight = false;
        } else if (keyCode == KeyEvent.VK_HOME || keyCode == KeyEvent.VK_Q) {
            // Turn camera to the left
            keyPressedTurnLeft = false;
        } else if (keyCode == KeyEvent.VK_PAGE_UP || keyCode == KeyEvent.VK_E) {
            // Turn camera to the right
            keyPressedTurnRight = false;
        } else if (keyCode == KeyEvent.VK_SPACE) {
            // Move camera up
            keyPressedSpace = false;
        } else if (keyCode == KeyEvent.VK_CONTROL) {
            // Move Camera down
            keyPressedControl = false;
        } else if (keyCode == KeyEvent.VK_SHIFT) {
            //hold shift to "sprint"
            keyPressedShift = false;
        }
}
}

import org.joml.Vector2f;
import org.joml.Vector3f;

import java.io.*;
import java.nio.file.Files;
import java.util.ArrayList;

public class ImportedModel {
private Vector3f[ ] vertices;
private Vector2f[ ] texCoords;
private Vector3f[] normals;
private int numVertices;

public ImportedModel(String filename) {
    ModelImporter modelImporter = new ModelImporter();

    try {
        modelImporter.parseOBJ(filename);   // uses modelImporter to get vertex information
        numVertices = modelImporter.getNumVertices();
        float[ ] verts = modelImporter.getVertices();
        float[ ] tcs = modelImporter.getTextureCoordinates();
        float[ ] norm = modelImporter.getNormals();

        this.vertices = new Vector3f[numVertices];
        this.texCoords = new Vector2f[numVertices];
        this.normals = new Vector3f[numVertices];

        for(int i=0; i<vertices.length; i++)
        { vertices[i] = new Vector3f();
            vertices[i].set(verts[i*3], verts[i*3+1], verts[i*3+2]);
            texCoords[i] = new Vector2f();
            texCoords[i].set(tcs[i*2], tcs[i*2+1]);
            this.normals[i] = new Vector3f();
            this.normals[i].set(norm[i*3], norm[i*3+1], norm[i*3+2]);
        }
    } catch (IOException e)
    { e.printStackTrace();
    } }
public int getNumVertices() { return numVertices; } // accessors
public Vector3f[ ] getVertices() { return vertices; }
public Vector2f[ ] getTexCoords() { return texCoords; }
public Vector3f[ ] getNormals() { return normals; }

private static class ModelImporter
{ // values as read in from OBJ file
    private final ArrayList<Float> vertVals = new ArrayList<>();
    private final ArrayList<Float> stVals = new ArrayList<>();
    private final ArrayList<Float> normVals = new ArrayList<>();
    // values stored for later use as vertex attributes
    private final ArrayList<Float> triangleVerts = new ArrayList<>();
    private final ArrayList<Float> textureCoords = new ArrayList<>();
    private final ArrayList<Float> normals = new ArrayList<>();
    public void parseOBJ(String filename) throws IOException
    {   InputStream input = Files.newInputStream(new File(filename).toPath());
        BufferedReader br = new BufferedReader(new InputStreamReader(input));
        String line;
        while ((line = br.readLine()) != null)
        {    if(line.startsWith("v"))        // vertex position ("v" case)
        {   for(String s : (line.substring(2)).split(" "))
        {   vertVals.add(Float.valueOf(s));    // extract the vertex position values
        } }
        else if(line.startsWith("vt"))        // texture coordinates ("vt" case)
        {   for(String s : (line.substring(3)).split(" "))
        {   stVals.add(Float.valueOf(s));     // extract the texture coordinate values
        } }
        else if(line.startsWith("vn"))        // vertex normals ("vn" case)
        {   for(String s : (line.substring(3)).split(" "))
        {   normVals.add(Float.valueOf(s));    // extract the normal vector values
        } }
        else if(line.startsWith("f"))         // triangle faces ("f" case)
        {   for(String s : (line.substring(2)).split(" "))
        {   String v = s.split("/")[0];        // extract triangle face references
            String vt = s.split("/")[1];
            String vn = s.split("/")[2];
            int vertRef = (Integer.parseInt(v)-1)*3;
            int tcRef = (Integer.parseInt(vt)-1)*2;
            int normRef = (Integer.parseInt(vn)-1)*3;
            triangleVerts.add(vertVals.get(vertRef));   // build array of vertices
            triangleVerts.add(vertVals.get(vertRef+1));
            triangleVerts.add(vertVals.get(vertRef+2));
            textureCoords.add(stVals.get(tcRef));   // build array of
            textureCoords.add(stVals.get(tcRef+1));     // texture coordinates.
            normals.add(normVals.get(normRef));     //… and normals
            normals.add(normVals.get(normRef+1));
            normals.add(normVals.get(normRef+2));
        } }}
        System.out.println(vertVals);
        System.out.println(stVals);
        System.out.println(normVals);
        input.close();
    }
    // accessors for retrieving the number of vertices, the vertices themselves,
    // and the corresponding texture coordinates and normals (only called once per model)
    public int getNumVertices() { return (triangleVerts.size()/3); }
    public float[ ] getVertices()
    {   float[ ] p = new float[triangleVerts.size()];
        for(int i = 0; i < triangleVerts.size(); i++)
        { p[i] = triangleVerts.get(i);
        }
        return p;
    }

    public float[] getTextureCoordinates() {
        float[] p = new float[textureCoords.size()];
        for (int i = 0; i < textureCoords.size(); i++) {
            p[i] = textureCoords.get(i);
        }
        return p;
}
    public float[] getNormals() {
        float[ ] p = new float[normals.size()];
        for(int i = 0; i < normals.size(); i++)
        { p[i] = normals.get(i);
        }
        return p;
    }
    // similar accessors for texture coordinates and normal vectors go here
} }
</code>```

Here are the errors I am getting:

```<code>Exception in thread "main-AWTAnimator#00" com.jogamp.opengl.util.AnimatorBase$UncaughtAnimatorException: java.lang.RuntimeException: com.jogamp.opengl.GLException: Caught NumberFormatException: empty String on thread AWT-EventQueue-0
    at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:92)
    at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:452)
    at com.jogamp.opengl.util.Animator$MainLoop.run(Animator.java:204)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.RuntimeException: com.jogamp.opengl.GLException: Caught NumberFormatException: empty String on thread AWT-EventQueue-0
    at com.jogamp.common.util.awt.AWTEDTExecutor.invoke(AWTEDTExecutor.java:58)
    at jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(AWTThreadingPlugin.java:103)
    at jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread(ThreadingImpl.java:201)
    at com.jogamp.opengl.Threading.invokeOnOpenGLThread(Threading.java:202)
    at com.jogamp.opengl.Threading.invoke(Threading.java:221)
    at com.jogamp.opengl.awt.GLCanvas.display(GLCanvas.java:505)
    at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:81)
    ... 3 more
Caused by: com.jogamp.opengl.GLException: Caught NumberFormatException: empty String on thread AWT-EventQueue-0
    at com.jogamp.opengl.GLException.newGLException(GLException.java:76)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1327)
    at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147)
    at com.jogamp.opengl.awt.GLCanvas$12.run(GLCanvas.java:1438)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.NumberFormatException: empty String
    at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1842)
    at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
    at java.lang.Float.parseFloat(Float.java:451)
    at java.lang.Float.valueOf(Float.java:416)
    at ImportedModel$ModelImporter.parseOBJ(ImportedModel.java:60)
    at ImportedModel.<init>(ImportedModel.java:18)
    at WalkingTour.init(WalkingTour.java:83)
    at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:644)
    at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:667)
    at com.jogamp.opengl.awt.GLCanvas$10.run(GLCanvas.java:1407)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1291)
    ... 16 more
Exception in thread "AWT-EventQueue-0" com.jogamp.opengl.GLException: Caught GLException: array vertex_buffer_object must be bound to call this method on thread AWT-EventQueue-0
    at com.jogamp.opengl.GLException.newGLException(GLException.java:76)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1327)
    at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147)
    at com.jogamp.opengl.awt.GLCanvas$12.run(GLCanvas.java:1438)
    at com.jogamp.opengl.Threading.invoke(Threading.java:223)
    at com.jogamp.opengl.awt.GLCanvas.display(GLCanvas.java:505)
    at com.jogamp.opengl.awt.GLCanvas.paint(GLCanvas.java:559)
    at sun.awt.RepaintArea.paintComponent(RepaintArea.java:264)
    at sun.lwawt.LWRepaintArea.paintComponent(LWRepaintArea.java:59)
    at sun.awt.RepaintArea.paint(RepaintArea.java:240)
    at sun.lwawt.LWComponentPeer.handleJavaPaintEvent(LWComponentPeer.java:1314)
    at sun.lwawt.LWComponentPeer.handleEvent(LWComponentPeer.java:1198)
    at java.awt.Component.dispatchEventImpl(Component.java:4965)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: com.jogamp.opengl.GLException: array vertex_buffer_object must be bound to call this method
    at jogamp.opengl.gl4.GL4bcImpl.checkBufferObject(GL4bcImpl.java:40621)
    at jogamp.opengl.gl4.GL4bcImpl.checkArrayVBOBound(GL4bcImpl.java:40653)
    at jogamp.opengl.gl4.GL4bcImpl.glVertexAttribPointer(GL4bcImpl.java:12429)
    at WalkingTour.display(WalkingTour.java:180)
    at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:692)
    at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:674)
    at com.jogamp.opengl.awt.GLCanvas$11.run(GLCanvas.java:1424)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293)
    ... 30 more
Exception in thread "AWT-EventQueue-0" com.jogamp.opengl.GLException: Caught GLException: array vertex_buffer_object must be bound to call this method on thread AWT-EventQueue-0
    at com.jogamp.opengl.GLException.newGLException(GLException.java:76)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1327)
    at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147)
    at com.jogamp.opengl.awt.GLCanvas$12.run(GLCanvas.java:1438)
    at com.jogamp.opengl.Threading.invoke(Threading.java:223)
    at com.jogamp.opengl.awt.GLCanvas.display(GLCanvas.java:505)
    at com.jogamp.opengl.awt.GLCanvas.paint(GLCanvas.java:559)
    at com.jogamp.opengl.awt.GLCanvas.update(GLCanvas.java:866)
    at sun.awt.RepaintArea.updateComponent(RepaintArea.java:255)
    at sun.lwawt.LWRepaintArea.updateComponent(LWRepaintArea.java:47)
    at sun.awt.RepaintArea.paint(RepaintArea.java:232)
    at sun.lwawt.LWComponentPeer.handleJavaPaintEvent(LWComponentPeer.java:1314)
    at sun.lwawt.LWComponentPeer.handleEvent(LWComponentPeer.java:1198)
    at java.awt.Component.dispatchEventImpl(Component.java:4965)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: com.jogamp.opengl.GLException: array vertex_buffer_object must be bound to call this method
    at jogamp.opengl.gl4.GL4bcImpl.checkBufferObject(GL4bcImpl.java:40621)
    at jogamp.opengl.gl4.GL4bcImpl.checkArrayVBOBound(GL4bcImpl.java:40653)
    at jogamp.opengl.gl4.GL4bcImpl.glVertexAttribPointer(GL4bcImpl.java:12429)
    at WalkingTour.display(WalkingTour.java:180)
    at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:692)
    at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:674)
    at com.jogamp.opengl.awt.GLCanvas$11.run(GLCanvas.java:1424)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293)
    ... 31 more
</code>```

Any help would be appreciated.

Trying to parse a .obj model and use the extracted information to load my model into a JOGL program.

Title: Errors loading Blender Wavefront Model

Body:
Hopefully someone can help me. I am trying to load a model I made in Blender into my JOGL program. I was able to manual models working and set up my window but there is something wrong with parsing the .obj wavefront file. No errors in my code that I can see, the ImportedModel class came from a textbook.

Here is the code:

import com.jogamp.common.nio.Buffers;
import com.jogamp.opengl.*;
import com.jogamp.opengl.awt.GLCanvas;
import com.jogamp.opengl.util.Animator;
import org.joml.Matrix4f;
import org.joml.Vector2f;
import org.joml.Vector3f;

import javax.swing.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List;

import static com.jogamp.opengl.GL.*;

public class WalkingTour extends JFrame implements GLEventListener, KeyListener {

private static final int windowWidth = 800, windowHeight = 600;
private static final String windowTitle = "Walking Tour";
private static final String vertexShaderFile = "src/walkingtour-vertex.glsl",
        fragmentShaderFile = "src/walkingtour-fragment.glsl";
private final GLCanvas glCanvas;
private int renderingProgram;
private final int[] vao = new int[1];
private final int[] vbo = new int[6];
private final FloatBuffer values = Buffers.newDirectFloatBuffer(16);
private final Matrix4f pMat = new Matrix4f();  // perspective matrix
private final Matrix4f vMat = new Matrix4f();  // view matrix
private final Matrix4f mMat = new Matrix4f();  // model matrix
private final Matrix4f mvMat = new Matrix4f(); // model-view matrix
private int gTexture;
private ImportedModel myModel;
private int numObjVertices;

private boolean keyPressedForward = false,
        keyPressedBackward = false,
        keyPressedMoveRight = false,
        keyPressedMoveLeft = false,
        keyPressedTurnRight = false,
        keyPressedTurnLeft = false,
        keyPressedSpace = false,
        keyPressedControl = false,
        keyPressedShift = false;
private final ArrayList<Float> vertexValues = new ArrayList<>();
private final ArrayList<Float> stVals = new ArrayList<>();
private final ArrayList<Float> normalValues = new ArrayList<>();

private final ArrayList<Float> triangleVerts = new ArrayList<>();
private final ArrayList<Float> textureCoordinates = new ArrayList<>();
private final ArrayList<Float> normals = new ArrayList<>();

private List<float[]> vertices = new ArrayList<float[]>();
private List<int[]> faces =new ArrayList<int[]>();

public WalkingTour() {
    setTitle(windowTitle);
    setSize(windowWidth, windowHeight);
    glCanvas = new GLCanvas(new GLCapabilities(GLProfile.getMaxProgrammableCore(true)));
    glCanvas.addGLEventListener(this);
    this.add(glCanvas);
    this.setVisible(true);
    Animator animator = new Animator(glCanvas);
    animator.start();
}

public static void main(String[] args) {
    new WalkingTour();
}

@Override
public void init(GLAutoDrawable glAutoDrawable) {

    myModel = new ImportedModel("hwk5Model.obj");

    GL4 gl = (GL4) GLContext.getCurrentGL();

    numObjVertices = myModel.getNumVertices();
    Vector3f[ ] vertices = myModel.getVertices();
    Vector2f[ ] texCoords = myModel.getTexCoords();
    Vector3f[ ] normals = myModel.getNormals();
    float[ ] pvalues = new float[numObjVertices*3];        // vertex positions
    float[ ] tvalues = new float[numObjVertices*2];        // texture coordinates
    float[ ] nvalues = new float[numObjVertices*3];        // normal vectors

    for (int i=0; i<numObjVertices; i++)
    {   pvalues[i*3]   = (float) (vertices[i]).x();
        pvalues[i*3+1]     = (float) (vertices[i]).y();
        pvalues[i*3+2]  = (float) (vertices[i]).z();
        tvalues[i*2]    = (float) (texCoords[i]).x();
        tvalues[i*2+1]  = (float) (texCoords[i]).y();
        nvalues[i*3]    = (float) (normals[i]).x();
        nvalues[i*3+1]  = (float) (normals[i]).y();
        nvalues[i*3+2]  = (float) (normals[i]).z();
    }

    // VBO for vertex locations
    gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[2]);
    FloatBuffer vertBuf = Buffers.newDirectFloatBuffer(pvalues);
    gl.glBufferData(GL_ARRAY_BUFFER, vertBuf.limit()*4, vertBuf, GL_STATIC_DRAW);
// VBO for texture coordinates
    gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[3]);
    FloatBuffer texBuf = Buffers.newDirectFloatBuffer(tvalues);
    gl.glBufferData(GL_ARRAY_BUFFER, texBuf.limit()*4, texBuf, GL_STATIC_DRAW);
// VBO for normal vectors
    gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[4]);
    FloatBuffer norBuf = Buffers.newDirectFloatBuffer(nvalues);
    gl.glBufferData(GL_ARRAY_BUFFER, norBuf.limit()*4,norBuf, GL_STATIC_DRAW);

    renderingProgram = Utils.createShaderProgram(vertexShaderFile, fragmentShaderFile);
    gTexture = Utils.loadTexture("groundTexture.jpeg");
    gl.glActiveTexture(GL_TEXTURE0);
    gl.glBindTexture(GL_TEXTURE_2D, gTexture);

    float[] floor = {
            -2000.0f, -50.0f, -2000.0f, -2000.0f, -50.0f, 2000.0f, 2000.0f, -50.0f, 2000.0f,
            -2000.0f, -50.0f, -2000.0f, 2000.0f, -50.0f, -2000.0f, 2000.0f, -50.0f, 2000.0f,
    };

    gl.glGenVertexArrays(vao.length, vao, 0);
    gl.glBindVertexArray(vao[0]);
    gl.glGenBuffers(vbo.length, vbo, 0);

    FloatBuffer corBuf = Buffers.newDirectFloatBuffer(floor);
    gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
    gl.glBufferData(GL_ARRAY_BUFFER, corBuf.limit() * 4L, corBuf, GL_STATIC_DRAW);

    float[] textureCoords = {
            0f, 1f, 0f, 0f, 1f, 0f,
            0f, 1f, 1f, 1f, 1f, 0f
    };

    FloatBuffer textureBuffer = Buffers.newDirectFloatBuffer(textureCoords);
    gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[1]);
    gl.glBufferData(GL_ARRAY_BUFFER, textureBuffer.limit() * 4L, textureBuffer, GL_STATIC_DRAW);

    this.addKeyListener(this);
}

@Override
public void dispose(GLAutoDrawable glAutoDrawable) {
    this.removeKeyListener(this);
}

@Override
public void display(GLAutoDrawable glAutoDrawable) {
    GL4 gl = (GL4) GLContext.getCurrentGL();

    gl.glClear(GL_COLOR_BUFFER_BIT);
    gl.glClear(GL_DEPTH_BUFFER_BIT);
    gl.glUseProgram(renderingProgram);

    int mvLoc = gl.glGetUniformLocation(renderingProgram, "mv_matrix");
    int pLoc = gl.glGetUniformLocation(renderingProgram, "p_matrix");

    float aspect = (float) glCanvas.getWidth() / (float) glCanvas.getHeight();
    pMat.identity().setPerspective((float) Math.toRadians(60.0f), aspect, 0.1f, 5000.0f);
    gl.glUniformMatrix4fv(pLoc, 1, false, pMat.get(values));

    vMat.translate(0f,0f,0f);

    mvMat.identity();
    mvMat.mul(vMat);
    mvMat.mul(mMat);

    gl.glUniformMatrix4fv(mvLoc, 1, false, mvMat.get(values));
    gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
    gl.glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0);
    gl.glEnableVertexAttribArray(0);
    gl.glEnable(GL_DEPTH_TEST);
    gl.glDepthFunc(GL_LEQUAL);

    gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[1]);
    gl.glVertexAttribPointer(1, 2, GL_FLOAT, false, 0, 0);
    gl.glEnableVertexAttribArray(1);

    gl.glBindTexture(GL_TEXTURE_2D, gTexture);
    gl.glDrawArrays(GL_TRIANGLES, 0, 6);
    gl.glDrawArrays(GL_TRIANGLES, 0, myModel.getNumVertices());

    if (keyPressedForward) {
        vMat.translateLocal(0f, 0f, 0.1f);
    }
    if (keyPressedBackward) {
        vMat.translateLocal(0f,0f,-0.1f);
    }
    if (keyPressedMoveLeft) {
        vMat.translateLocal(0.1f,0f,0f);
    }
    if (keyPressedMoveRight) {
        vMat.translateLocal(-0.1f,0f,0f);
    }
    if (keyPressedTurnLeft) {
        vMat.rotateLocalY(-0.001f);
    }
    if (keyPressedTurnRight) {
        vMat.rotateLocalY(0.001f);
    }
    if (keyPressedSpace) {
        vMat.translateLocal(0f,-0.1f,0f);
    }
    if (keyPressedControl) {
        vMat.translateLocal(0f,0.1f,0f);
    }
    if (keyPressedForward && keyPressedShift){
        vMat.translateLocal(0f,0f,0.2f);
    }

}

@Override
public void reshape(GLAutoDrawable glAutoDrawable, int i, int i1, int i2, int i3) {

}

@Override
public void keyTyped(KeyEvent e) {
    //do nothing
}

@Override
public void keyPressed(KeyEvent e) {
    int keyCode = e.getKeyCode();
    if (keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_W) {
        // Move camera forward
        keyPressedForward = true;
    } else if (keyCode == KeyEvent.VK_DOWN || keyCode == KeyEvent.VK_S) {
        // Move camera backward
        keyPressedBackward = true;
    } else if (keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_A) {
        // Move camera to the left
        keyPressedMoveLeft = true;
    } else if (keyCode == KeyEvent.VK_RIGHT || keyCode == KeyEvent.VK_D) {
        // Move camera to the right
        keyPressedMoveRight = true;
    } else if (keyCode == KeyEvent.VK_HOME || keyCode == KeyEvent.VK_Q) {
        // Turn camera to the left
        keyPressedTurnLeft = true;
    } else if (keyCode == KeyEvent.VK_PAGE_UP || keyCode == KeyEvent.VK_E) {
        // Turn camera to the right
        keyPressedTurnRight = true;
    } else if (keyCode == KeyEvent.VK_SPACE) {
        // Move camera up
        keyPressedSpace = true;
    } else if (keyCode == KeyEvent.VK_CONTROL) {
        // Move camera down
        keyPressedControl = true;
    } else if (keyCode == KeyEvent.VK_SHIFT) {
        //hold shift to "sprint"
        //can only sprint while forward buttons are pressed
        keyPressedShift = true;
    }
}

@Override
public void keyReleased(KeyEvent e) {
    int keyCode = e.getKeyCode();
        if (keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_W) {
            // Move camera forward
            keyPressedForward = false;
        } else if (keyCode == KeyEvent.VK_DOWN || keyCode == KeyEvent.VK_S) {
            // Move camera backward
            keyPressedBackward = false;
        } else if (keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_A) {
            // Move camera to the left
            keyPressedMoveLeft = false;
        } else if (keyCode == KeyEvent.VK_RIGHT || keyCode == KeyEvent.VK_D) {
            // Move camera to the right
            keyPressedMoveRight = false;
        } else if (keyCode == KeyEvent.VK_HOME || keyCode == KeyEvent.VK_Q) {
            // Turn camera to the left
            keyPressedTurnLeft = false;
        } else if (keyCode == KeyEvent.VK_PAGE_UP || keyCode == KeyEvent.VK_E) {
            // Turn camera to the right
            keyPressedTurnRight = false;
        } else if (keyCode == KeyEvent.VK_SPACE) {
            // Move camera up
            keyPressedSpace = false;
        } else if (keyCode == KeyEvent.VK_CONTROL) {
            // Move Camera down
            keyPressedControl = false;
        } else if (keyCode == KeyEvent.VK_SHIFT) {
            //hold shift to "sprint"
            keyPressedShift = false;
        }
}
}

import org.joml.Vector2f;
import org.joml.Vector3f;

import java.io.*;
import java.nio.file.Files;
import java.util.ArrayList;

public class ImportedModel {
private Vector3f[ ] vertices;
private Vector2f[ ] texCoords;
private Vector3f[] normals;
private int numVertices;

public ImportedModel(String filename) {
    ModelImporter modelImporter = new ModelImporter();

    try {
        modelImporter.parseOBJ(filename);   // uses modelImporter to get vertex information
        numVertices = modelImporter.getNumVertices();
        float[ ] verts = modelImporter.getVertices();
        float[ ] tcs = modelImporter.getTextureCoordinates();
        float[ ] norm = modelImporter.getNormals();

        this.vertices = new Vector3f[numVertices];
        this.texCoords = new Vector2f[numVertices];
        this.normals = new Vector3f[numVertices];

        for(int i=0; i<vertices.length; i++)
        { vertices[i] = new Vector3f();
            vertices[i].set(verts[i*3], verts[i*3+1], verts[i*3+2]);
            texCoords[i] = new Vector2f();
            texCoords[i].set(tcs[i*2], tcs[i*2+1]);
            this.normals[i] = new Vector3f();
            this.normals[i].set(norm[i*3], norm[i*3+1], norm[i*3+2]);
        }
    } catch (IOException e)
    { e.printStackTrace();
    } }
public int getNumVertices() { return numVertices; } // accessors
public Vector3f[ ] getVertices() { return vertices; }
public Vector2f[ ] getTexCoords() { return texCoords; }
public Vector3f[ ] getNormals() { return normals; }

private static class ModelImporter
{ // values as read in from OBJ file
    private final ArrayList<Float> vertVals = new ArrayList<>();
    private final ArrayList<Float> stVals = new ArrayList<>();
    private final ArrayList<Float> normVals = new ArrayList<>();
    // values stored for later use as vertex attributes
    private final ArrayList<Float> triangleVerts = new ArrayList<>();
    private final ArrayList<Float> textureCoords = new ArrayList<>();
    private final ArrayList<Float> normals = new ArrayList<>();
    public void parseOBJ(String filename) throws IOException
    {   InputStream input = Files.newInputStream(new File(filename).toPath());
        BufferedReader br = new BufferedReader(new InputStreamReader(input));
        String line;
        while ((line = br.readLine()) != null)
        {    if(line.startsWith("v"))        // vertex position ("v" case)
        {   for(String s : (line.substring(2)).split(" "))
        {   vertVals.add(Float.valueOf(s));    // extract the vertex position values
        } }
        else if(line.startsWith("vt"))        // texture coordinates ("vt" case)
        {   for(String s : (line.substring(3)).split(" "))
        {   stVals.add(Float.valueOf(s));     // extract the texture coordinate values
        } }
        else if(line.startsWith("vn"))        // vertex normals ("vn" case)
        {   for(String s : (line.substring(3)).split(" "))
        {   normVals.add(Float.valueOf(s));    // extract the normal vector values
        } }
        else if(line.startsWith("f"))         // triangle faces ("f" case)
        {   for(String s : (line.substring(2)).split(" "))
        {   String v = s.split("/")[0];        // extract triangle face references
            String vt = s.split("/")[1];
            String vn = s.split("/")[2];
            int vertRef = (Integer.parseInt(v)-1)*3;
            int tcRef = (Integer.parseInt(vt)-1)*2;
            int normRef = (Integer.parseInt(vn)-1)*3;
            triangleVerts.add(vertVals.get(vertRef));   // build array of vertices
            triangleVerts.add(vertVals.get(vertRef+1));
            triangleVerts.add(vertVals.get(vertRef+2));
            textureCoords.add(stVals.get(tcRef));   // build array of
            textureCoords.add(stVals.get(tcRef+1));     // texture coordinates.
            normals.add(normVals.get(normRef));     //… and normals
            normals.add(normVals.get(normRef+1));
            normals.add(normVals.get(normRef+2));
        } }}
        System.out.println(vertVals);
        System.out.println(stVals);
        System.out.println(normVals);
        input.close();
    }
    // accessors for retrieving the number of vertices, the vertices themselves,
    // and the corresponding texture coordinates and normals (only called once per model)
    public int getNumVertices() { return (triangleVerts.size()/3); }
    public float[ ] getVertices()
    {   float[ ] p = new float[triangleVerts.size()];
        for(int i = 0; i < triangleVerts.size(); i++)
        { p[i] = triangleVerts.get(i);
        }
        return p;
    }

    public float[] getTextureCoordinates() {
        float[] p = new float[textureCoords.size()];
        for (int i = 0; i < textureCoords.size(); i++) {
            p[i] = textureCoords.get(i);
        }
        return p;
}
    public float[] getNormals() {
        float[ ] p = new float[normals.size()];
        for(int i = 0; i < normals.size(); i++)
        { p[i] = normals.get(i);
        }
        return p;
    }
    // similar accessors for texture coordinates and normal vectors go here
} }

Here are the errors I am getting:

Exception in thread "main-AWTAnimator#00" com.jogamp.opengl.util.AnimatorBase$UncaughtAnimatorException: java.lang.RuntimeException: com.jogamp.opengl.GLException: Caught NumberFormatException: empty String on thread AWT-EventQueue-0
    at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:92)
    at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:452)
    at com.jogamp.opengl.util.Animator$MainLoop.run(Animator.java:204)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.RuntimeException: com.jogamp.opengl.GLException: Caught NumberFormatException: empty String on thread AWT-EventQueue-0
    at com.jogamp.common.util.awt.AWTEDTExecutor.invoke(AWTEDTExecutor.java:58)
    at jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(AWTThreadingPlugin.java:103)
    at jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread(ThreadingImpl.java:201)
    at com.jogamp.opengl.Threading.invokeOnOpenGLThread(Threading.java:202)
    at com.jogamp.opengl.Threading.invoke(Threading.java:221)
    at com.jogamp.opengl.awt.GLCanvas.display(GLCanvas.java:505)
    at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:81)
    ... 3 more
Caused by: com.jogamp.opengl.GLException: Caught NumberFormatException: empty String on thread AWT-EventQueue-0
    at com.jogamp.opengl.GLException.newGLException(GLException.java:76)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1327)
    at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147)
    at com.jogamp.opengl.awt.GLCanvas$12.run(GLCanvas.java:1438)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.NumberFormatException: empty String
    at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1842)
    at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
    at java.lang.Float.parseFloat(Float.java:451)
    at java.lang.Float.valueOf(Float.java:416)
    at ImportedModel$ModelImporter.parseOBJ(ImportedModel.java:60)
    at ImportedModel.<init>(ImportedModel.java:18)
    at WalkingTour.init(WalkingTour.java:83)
    at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:644)
    at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:667)
    at com.jogamp.opengl.awt.GLCanvas$10.run(GLCanvas.java:1407)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1291)
    ... 16 more
Exception in thread "AWT-EventQueue-0" com.jogamp.opengl.GLException: Caught GLException: array vertex_buffer_object must be bound to call this method on thread AWT-EventQueue-0
    at com.jogamp.opengl.GLException.newGLException(GLException.java:76)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1327)
    at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147)
    at com.jogamp.opengl.awt.GLCanvas$12.run(GLCanvas.java:1438)
    at com.jogamp.opengl.Threading.invoke(Threading.java:223)
    at com.jogamp.opengl.awt.GLCanvas.display(GLCanvas.java:505)
    at com.jogamp.opengl.awt.GLCanvas.paint(GLCanvas.java:559)
    at sun.awt.RepaintArea.paintComponent(RepaintArea.java:264)
    at sun.lwawt.LWRepaintArea.paintComponent(LWRepaintArea.java:59)
    at sun.awt.RepaintArea.paint(RepaintArea.java:240)
    at sun.lwawt.LWComponentPeer.handleJavaPaintEvent(LWComponentPeer.java:1314)
    at sun.lwawt.LWComponentPeer.handleEvent(LWComponentPeer.java:1198)
    at java.awt.Component.dispatchEventImpl(Component.java:4965)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: com.jogamp.opengl.GLException: array vertex_buffer_object must be bound to call this method
    at jogamp.opengl.gl4.GL4bcImpl.checkBufferObject(GL4bcImpl.java:40621)
    at jogamp.opengl.gl4.GL4bcImpl.checkArrayVBOBound(GL4bcImpl.java:40653)
    at jogamp.opengl.gl4.GL4bcImpl.glVertexAttribPointer(GL4bcImpl.java:12429)
    at WalkingTour.display(WalkingTour.java:180)
    at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:692)
    at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:674)
    at com.jogamp.opengl.awt.GLCanvas$11.run(GLCanvas.java:1424)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293)
    ... 30 more
Exception in thread "AWT-EventQueue-0" com.jogamp.opengl.GLException: Caught GLException: array vertex_buffer_object must be bound to call this method on thread AWT-EventQueue-0
    at com.jogamp.opengl.GLException.newGLException(GLException.java:76)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1327)
    at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147)
    at com.jogamp.opengl.awt.GLCanvas$12.run(GLCanvas.java:1438)
    at com.jogamp.opengl.Threading.invoke(Threading.java:223)
    at com.jogamp.opengl.awt.GLCanvas.display(GLCanvas.java:505)
    at com.jogamp.opengl.awt.GLCanvas.paint(GLCanvas.java:559)
    at com.jogamp.opengl.awt.GLCanvas.update(GLCanvas.java:866)
    at sun.awt.RepaintArea.updateComponent(RepaintArea.java:255)
    at sun.lwawt.LWRepaintArea.updateComponent(LWRepaintArea.java:47)
    at sun.awt.RepaintArea.paint(RepaintArea.java:232)
    at sun.lwawt.LWComponentPeer.handleJavaPaintEvent(LWComponentPeer.java:1314)
    at sun.lwawt.LWComponentPeer.handleEvent(LWComponentPeer.java:1198)
    at java.awt.Component.dispatchEventImpl(Component.java:4965)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: com.jogamp.opengl.GLException: array vertex_buffer_object must be bound to call this method
    at jogamp.opengl.gl4.GL4bcImpl.checkBufferObject(GL4bcImpl.java:40621)
    at jogamp.opengl.gl4.GL4bcImpl.checkArrayVBOBound(GL4bcImpl.java:40653)
    at jogamp.opengl.gl4.GL4bcImpl.glVertexAttribPointer(GL4bcImpl.java:12429)
    at WalkingTour.display(WalkingTour.java:180)
    at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:692)
    at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:674)
    at com.jogamp.opengl.awt.GLCanvas$11.run(GLCanvas.java:1424)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293)
    ... 31 more

Any help would be appreciated.

Trying to parse a .obj model and use the extracted information to load my model into a JOGL program.


来源: stackexchange

问:
Next.js + PM2 + IIS deployment - error when switching between pages quickly (Internal Server Error)
https://github.com/vercel/next.js/issues/33292

logs in PM2 show this error

| 2022-12-22T10:43:16: Error: invariant: static responses cannot be piped. This is a bug in Next.js

Any ideas on where I can debug?

ContentLicense: CC BY-SA 4.0


问:
Disable crawlers inside robots.txt file for all funnel pages
If inside the robots.txt of my app has this line:

User-agent: *
Disallow: /banana
```
<p>Question:
Do all other following URLs down the funnel for example:</p>
<pre class="lang-none prettyprint-override"><code>/banana-signup and
/banana-payment
</code>```

also have crawlers disabled on them or no?

The second question is:
if /banana has crawlers disabled, does that mean when user search in Google for example type in companyname/banana, it will not show up in search results?

What exactly does "disable crawlers on a URL" do?

Body:
If inside the robots.txt of my app has this line:

User-agent: *
Disallow: /banana

Question:
Do all other following URLs down the funnel for example:

/banana-signup and
/banana-payment

also have crawlers disabled on them or no?

The second question is:
if /banana has crawlers disabled, does that mean when user search in Google for example type in companyname/banana, it will not show up in search results?

What exactly does "disable crawlers on a URL" do?


问:
Chrome has invalid Post request header
First of all, I apologize for my bad English. Also, I would appreciate it if you could explain your answers simply, since I am only 15. My maths and programming skills are not so good yet.

I am currently trying to program an HTTP server from Scratch. I am in the process of implementing PHP, but I need to read many values from the header.

The code works with Edge, OperaGX and even Internet Explorer. But Google Chrome doesn't send the values from the POST form, so I can't read them either.

Because I can't read the values, I can't pass them to PHP. And because of this, the $_POST variable doesn't work when the user is using Chrome.

If someone wants to reproduce the whole thing (its currently windows only), here is the py code:
https://pastebin.com/8qmx7G5G.  And to start the Server:

```<code>def main() -> None:
    server: Server = Server(docs_dir='docs', port=3033)
    server.activate_php(php_dir='C:\\php',
                        php_ini='c:\\php\\php.ini')
    server.start()
</code>```

Anyway, an POST request usually looks like this:

```<code>POST /index.php?submit=1 HTTP/1.0
Accept: ...
Refferer: ...

username=Fido&password=example
</code>```

But chrome sends only:

```<code>POST /index.php?submit=1 HTTP/1.0
Accept: ...
Refferer: ...
</code>```

It's not loading the .php file, after submit the form. Its only raising Error ERR_CONNECTION_RESET.

Update:
When i access my localhost over http://localhost:3033, then it's not working (Only in Chrome, in Edge, IE and Opera its working). But if i access it with http://192.168.178.45:3033 then it's working. Is this perhaps a security feature of Chrome?

Title: Chrome has invalid Post request header

Body:
First of all, I apologize for my bad English. Also, I would appreciate it if you could explain your answers simply, since I am only 15. My maths and programming skills are not so good yet.

I am currently trying to program an HTTP server from Scratch. I am in the process of implementing PHP, but I need to read many values from the header.

The code works with Edge, OperaGX and even Internet Explorer. But Google Chrome doesn't send the values from the POST form, so I can't read them either.

Because I can't read the values, I can't pass them to PHP. And because of this, the $_POST variable doesn't work when the user is using Chrome.

If someone wants to reproduce the whole thing (its currently windows only), here is the py code:
https://pastebin.com/8qmx7G5G.  And to start the Server:

def main() -> None:
    server: Server = Server(docs_dir='docs', port=3033)
    server.activate_php(php_dir='C:\\php',
                        php_ini='c:\\php\\php.ini')
    server.start()

Anyway, an POST request usually looks like this:

POST /index.php?submit=1 HTTP/1.0
Accept: ...
Refferer: ...

username=Fido&password=example

But chrome sends only:

POST /index.php?submit=1 HTTP/1.0
Accept: ...
Refferer: ...

It's not loading the .php file, after submit the form. Its only raising Error ERR_CONNECTION_RESET.

Update:
When i access my localhost over http://localhost:3033, then it's not working (Only in Chrome, in Edge, IE and Opera its working). But if i access it with http://192.168.178.45:3033 then it's working. Is this perhaps a security feature of Chrome?


问:
Scroll down through a list of the same element and fetch data selenium python
I want to fetch data by iterating through a list of eleme3nt. I will need to scroll to an each item in the list before I can fetch the data. Each scroll contains the same element but I want to iterate through the elements. Besides the first element, I need to scroll to view and fetch data from the next element. My code below scrolls only ones and throws error.

What I've tried:

```<code>from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import Select
import undetected_chromedriver as uc
import time
import pandas as pd
from selenium.webdriver import ActionChains

import tkinter as tk

options = uc.ChromeOptions()

driver = uc.Chrome(options=options)
website = 'https://douyin.com'

driver.get(website)
driver.implicitly_wait(10)
wait = WebDriverWait(driver, 20)
driver.maximize_window()
</code>```

LOGIN TO SITE

INPUT LOCATION & KEYWORD INTO SEARCH FIELD

```<code>web_list = []
e = 1

while e <= 5:

    time.sleep(2)
    e + 1

    name = driver.find_elements(By.XPATH, f'(//p[@class="_K3SLhVc"]//span/span/span/span/span/span)[{e}]')
    for value in name:
        value.text
    time.sleep(3)
    share_arrow = driver.find_element(By.XPATH, "(//div[@class='BwiwR0v7'])")
    actions.move_to_element(share_arrow)
    actions.perform()
    time.sleep(2)

    copy_link = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'div > button._FNKGf5B.W1wbuR_h > svg')))
    time.sleep(2)
    actions.move_to_element(copy_link).click().perform()
    time.sleep(2)

    root = tk.Tk()
    root.withdraw()
    copied_text = root.clipboard_get()

    driver.execute_script("window.scrollBy(0,800)","")

web_item = {
    'Location': location_query,
    'Key': keyword_query,
    'Name': name,
    'Copied_Links': copied_text

    }

web_list.append(web_item)
</code>```

Error Code

```<code>Traceback (most recent call last):

  File "C:\Users\Administrator\AppData\Local\Temp\2\ipykernel_2692\2751035614.py", line 22, in <module>
    copy_link = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'div > button._FNKGf5B.W1wbuR_h > svg')))

  File "C:\Users\Administrator\anaconda3\lib\site-packages\selenium\webdriver\support\wait.py", line 95, in until
    raise TimeoutException(message, screen, stacktrace)

TimeoutException'''

Please how do I scroll continously and the same time iterate through `name`, `copied_text` variables?
</code>```

Body:
I want to fetch data by iterating through a list of eleme3nt. I will need to scroll to an each item in the list before I can fetch the data. Each scroll contains the same element but I want to iterate through the elements. Besides the first element, I need to scroll to view and fetch data from the next element. My code below scrolls only ones and throws error.

What I've tried:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import Select
import undetected_chromedriver as uc
import time
import pandas as pd
from selenium.webdriver import ActionChains

import tkinter as tk

options = uc.ChromeOptions()

driver = uc.Chrome(options=options)
website = 'https://douyin.com'

driver.get(website)
driver.implicitly_wait(10)
wait = WebDriverWait(driver, 20)
driver.maximize_window()

LOGIN TO SITE

INPUT LOCATION & KEYWORD INTO SEARCH FIELD

web_list = []
e = 1

while e <= 5:

    time.sleep(2)
    e + 1

    name = driver.find_elements(By.XPATH, f'(//p[@class="_K3SLhVc"]//span/span/span/span/span/span)[{e}]')
    for value in name:
        value.text
    time.sleep(3)
    share_arrow = driver.find_element(By.XPATH, "(//div[@class='BwiwR0v7'])")
    actions.move_to_element(share_arrow)
    actions.perform()
    time.sleep(2)

    copy_link = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'div > button._FNKGf5B.W1wbuR_h > svg')))
    time.sleep(2)
    actions.move_to_element(copy_link).click().perform()
    time.sleep(2)

    root = tk.Tk()
    root.withdraw()
    copied_text = root.clipboard_get()

    driver.execute_script("window.scrollBy(0,800)","")

web_item = {
    'Location': location_query,
    'Key': keyword_query,
    'Name': name,
    'Copied_Links': copied_text

    }

web_list.append(web_item)

Error Code

Traceback (most recent call last):

  File "C:\Users\Administrator\AppData\Local\Temp\2\ipykernel_2692\2751035614.py", line 22, in <module>
    copy_link = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'div > button._FNKGf5B.W1wbuR_h > svg')))

  File "C:\Users\Administrator\anaconda3\lib\site-packages\selenium\webdriver\support\wait.py", line 95, in until
    raise TimeoutException(message, screen, stacktrace)

TimeoutException'''

Please how do I scroll continously and the same time iterate through `name`, `copied_text` variables?


问:
im trying to loop through array of coordinates and remove elements from array if they within x miles of any other element in in array
example:

```<code>        $arr =Array(
        Array("name1","lat1","lng1"),
        Array("name2","lat2","lng2"),
        Array("name3","lat3","lng3"),
        Array("name4","lat4","lng4"),
        Array("name5","lat5","lng5"),
        ) ;
</code>```

I have a function that will return miles apart from 2 different locations

```<code>        function is_within_x_miles($lat1, $lng1, $lat2, $lng2) {
              return $milesApart;
          }
</code>```

the idea is to return an array that makes sure every location is x miles apart from each other

Actual runnable code:

```<code>        <?php

        $arr =Array(Array(" exclusive-care-2"," 38.677892"," -121.31073"),
        Array(" the-re-up-citrus-heights-orangevale"," 38.689974"," -121.297324"),
        Array(" norcal-medicine-man-top-shelf-cards-accepted"," 38.718435"," -121.290412"),
        Array(" the-sanctuary-delivery-5"," 38.694406"," -121.302111"),
        Array(" canna-couriers-1"," 38.68"," -121.27"));

        foreach ($arr as $key => $value) {
          // loop through inner array
          foreach ($arr as $key2 => $value2) {
            // skip if same element in array
            if($key == $key2){
              continue;
            }
            // if distance is more than 2 miles remove from array
            $distance = distance($value[1],$value[2],$value2[1],$value2[2]);
            // visual output
            within_distance($distance, 2, $value[0], $value2[0]);
            if($distance > 2){
              unset($arr[$key]);
            }
          }
        }

        // show array
        echo '```';
        print_r($arr);
        echo '```';

        /* funtions*/
        // function to calculate distance between two points
        function distance($lat1, $lng1, $lat2, $lng2) {
          if (($lat1 == $lat2) && ($lng1 == $lng2)) {
            return 0;
          }
          else {
            $theta = $lng1 - $lng2;
            $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +  cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
            $dist = acos($dist);
            $dist = rad2deg($dist);
            $miles = $dist * 60 * 1.1515;
              return $miles;
          }
        }

        // function to show if distance is more than x miles
        function within_distance($distance, $miles, $name, $name2) {
            if ($distance > $miles) {
                echo '```'.$name .'  is '.$distance.' from  '.$name2.' ```';
              }else{
                echo '```'.$name .'  is '.$distance.' from  '.$name2.' ```';
            }
        }

</code>```

Output is

```<code>        exclusive-care-2  is 1 from   the-re-up-citrus-heights-orangevale
        exclusive-care-2  is 3 from   norcal-medicine-man-top-shelf-cards-accepted
        exclusive-care-2  is 1 from   the-sanctuary-delivery-5
        exclusive-care-2  is 2 from   canna-couriers-1
        the-re-up-citrus-heights-orangevale  is 2 from   norcal-medicine-man-top-shelf-cards-accepted
        the-re-up-citrus-heights-orangevale  is 0 from   the-sanctuary-delivery-5
        the-re-up-citrus-heights-orangevale  is 2 from   canna-couriers-1
        norcal-medicine-man-top-shelf-cards-accepted  is 2 from   the-sanctuary-delivery-5
        norcal-medicine-man-top-shelf-cards-accepted  is 3 from   canna-couriers-1
        the-sanctuary-delivery-5  is 2 from   canna-couriers-1
        canna-couriers-1  is 2 from   the-sanctuary-delivery-5

        final array:

        Array
        (
            [3] => Array
                (
                    [0] =>  the-sanctuary-delivery-5
                    [1] =>  38.694406
                    [2] =>  -121.302111
                )

            [4] => Array
                (
                    [0] =>  canna-couriers-1
                    [1] =>  38.68
                    [2] =>  -121.27
                )

        )
</code>```

The final array can't be correct because the-sanctuary-delivery-5 is under 2 miles from canna-couriers-1

I feel like as soon as the first interval ran the-re-up-citrus-heights-orangevale should have been removed from the array.

Body:
example:

        $arr =Array(
        Array("name1","lat1","lng1"),
        Array("name2","lat2","lng2"),
        Array("name3","lat3","lng3"),
        Array("name4","lat4","lng4"),
        Array("name5","lat5","lng5"),
        ) ;

I have a function that will return miles apart from 2 different locations

        function is_within_x_miles($lat1, $lng1, $lat2, $lng2) {
              return $milesApart;
          }

the idea is to return an array that makes sure every location is x miles apart from each other

Actual runnable code:

        <?php

        $arr =Array(Array(" exclusive-care-2"," 38.677892"," -121.31073"),
        Array(" the-re-up-citrus-heights-orangevale"," 38.689974"," -121.297324"),
        Array(" norcal-medicine-man-top-shelf-cards-accepted"," 38.718435"," -121.290412"),
        Array(" the-sanctuary-delivery-5"," 38.694406"," -121.302111"),
        Array(" canna-couriers-1"," 38.68"," -121.27"));

        foreach ($arr as $key => $value) {
          // loop through inner array
          foreach ($arr as $key2 => $value2) {
            // skip if same element in array
            if($key == $key2){
              continue;
            }
            // if distance is more than 2 miles remove from array
            $distance = distance($value[1],$value[2],$value2[1],$value2[2]);
            // visual output
            within_distance($distance, 2, $value[0], $value2[0]);
            if($distance > 2){
              unset($arr[$key]);
            }
          }
        }

        // show array
        echo '
';
        print_r($arr);
        echo '
';

        /* funtions*/
        // function to calculate distance between two points
        function distance($lat1, $lng1, $lat2, $lng2) {
          if (($lat1 == $lat2) && ($lng1 == $lng2)) {
            return 0;
          }
          else {
            $theta = $lng1 - $lng2;
            $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +  cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
            $dist = acos($dist);
            $dist = rad2deg($dist);
            $miles = $dist * 60 * 1.1515;
              return $miles;
          }
        }

        // function to show if distance is more than x miles
        function within_distance($distance, $miles, $name, $name2) {
            if ($distance > $miles) {
                echo '
'.$name .'  is '.$distance.' from  '.$name2.'
';
              }else{
                echo '
'.$name .'  is '.$distance.' from  '.$name2.'
';
            }
        }

Output is

        exclusive-care-2  is 1 from   the-re-up-citrus-heights-orangevale
        exclusive-care-2  is 3 from   norcal-medicine-man-top-shelf-cards-accepted
        exclusive-care-2  is 1 from   the-sanctuary-delivery-5
        exclusive-care-2  is 2 from   canna-couriers-1
        the-re-up-citrus-heights-orangevale  is 2 from   norcal-medicine-man-top-shelf-cards-accepted
        the-re-up-citrus-heights-orangevale  is 0 from   the-sanctuary-delivery-5
        the-re-up-citrus-heights-orangevale  is 2 from   canna-couriers-1
        norcal-medicine-man-top-shelf-cards-accepted  is 2 from   the-sanctuary-delivery-5
        norcal-medicine-man-top-shelf-cards-accepted  is 3 from   canna-couriers-1
        the-sanctuary-delivery-5  is 2 from   canna-couriers-1
        canna-couriers-1  is 2 from   the-sanctuary-delivery-5

        final array:

        Array
        (
            [3] => Array
                (
                    [0] =>  the-sanctuary-delivery-5
                    [1] =>  38.694406
                    [2] =>  -121.302111
                )

            [4] => Array
                (
                    [0] =>  canna-couriers-1
                    [1] =>  38.68
                    [2] =>  -121.27
                )

        )

The final array can't be correct because the-sanctuary-delivery-5 is under 2 miles from canna-couriers-1

I feel like as soon as the first interval ran the-re-up-citrus-heights-orangevale should have been removed from the array.


问:
I cant run my react native app after send to test flight
I'm developing an application with react native and I recently published it on the test flight for my beta testers to use the application, but now I need to continue developing but when  I run

```<code>react-native run-ios
</code>```

the application is installed on the emulator but the error appears:

Could not connect to development server.

Ensure the following:

Node server is running and available on the same network - run 'npm start' from react-native root

Node server URL is correctly set in AppDelegate

WiFi is enabled and connected to the same network as the Node Server

URL: http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=br.com.W2App

RCT Fatal
__28-[RCTCxxBridge handleError:]_block_invoke
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_main_queue_drain
_dispatch_main_queue_callback_4CF
CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE
__CFRunLoopRun
CFRunLoopRunSpecific
GSEventRunModal
-[UIApplication _run]
UIApplicationMain
main
start_yes
0x0
0x0

In the output log in the terminal appears:

2022-12-23 16:16:32.957 xcodebuild[44831:5288964] [MT] IDEFileReferenceDebug: [Load] <IDESwiftPackageCore.IDESwiftPackageSpecialFolderFileReference, 0x13bb0fc60: name:Docs.docc path:group:Docs.docc> Failed to load container at path : /Users/goattech/Library/Developer/Xcode/DerivedData/W2App-bcybuxjmeijubwcppznzxbonxojg/SourcePackages/checkouts/swift-protobuf/Sources/protoc-gen-swift/Docs.docc, Error: Error Domain=com.apple.dt.IDEContainerErrorDomain Code=6 "Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder"." UserInfo={NSLocalizedDescription=Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder".}

2022-12-23 16:16:38.199 xcodebuild[44831:5290006] Requested but did not find extension point with identifier Xcode.InterfaceBuilderBuildSupport.PlatformDefinition

info Installing "/Users/goattech/Library/Developer/Xcode/DerivedData/W2App-bcybuxjmeijubwcppznzxbonxojg/Build/Products/Debug-iphonesimulator/W2App.app"

info Launching "br.com.W2App"

success Successfully launched the app on the simulator

✨ Done in 111.36s.

I already changed the ios scheme from release to debug back but that didn't help, I need to run the app in development mode inside the IOS emulator

Body:
I'm developing an application with react native and I recently published it on the test flight for my beta testers to use the application, but now I need to continue developing but when  I run

react-native run-ios

the application is installed on the emulator but the error appears:

Could not connect to development server.

Ensure the following:

Node server is running and available on the same network - run 'npm start' from react-native root

Node server URL is correctly set in AppDelegate

WiFi is enabled and connected to the same network as the Node Server

URL: http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=br.com.W2App

RCT Fatal
__28-[RCTCxxBridge handleError:]_block_invoke
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_main_queue_drain
_dispatch_main_queue_callback_4CF
CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE
__CFRunLoopRun
CFRunLoopRunSpecific
GSEventRunModal
-[UIApplication _run]
UIApplicationMain
main
start_yes
0x0
0x0

In the output log in the terminal appears:

2022-12-23 16:16:32.957 xcodebuild[44831:5288964] [MT] IDEFileReferenceDebug: [Load] <IDESwiftPackageCore.IDESwiftPackageSpecialFolderFileReference, 0x13bb0fc60: name:Docs.docc path:group:Docs.docc> Failed to load container at path : /Users/goattech/Library/Developer/Xcode/DerivedData/W2App-bcybuxjmeijubwcppznzxbonxojg/SourcePackages/checkouts/swift-protobuf/Sources/protoc-gen-swift/Docs.docc, Error: Error Domain=com.apple.dt.IDEContainerErrorDomain Code=6 "Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder"." UserInfo={NSLocalizedDescription=Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder".}

2022-12-23 16:16:38.199 xcodebuild[44831:5290006] Requested but did not find extension point with identifier Xcode.InterfaceBuilderBuildSupport.PlatformDefinition

info Installing "/Users/goattech/Library/Developer/Xcode/DerivedData/W2App-bcybuxjmeijubwcppznzxbonxojg/Build/Products/Debug-iphonesimulator/W2App.app"

info Launching "br.com.W2App"

success Successfully launched the app on the simulator

✨ Done in 111.36s.

I already changed the ios scheme from release to debug back but that didn't help, I need to run the app in development mode inside the IOS emulator


问:
django super user premissions
i want to add if user is super user show companies  and add company anyone can help with what should add in class to do it
this is class code just showing in tepmalte page all comapany and add new company not working

views.py

```<code>class Companies(LoginRequiredMixin, FormView, ListView):
    """
    Company add edit delete view
    """
    model = Company
    template_name = 'company/index.html'
    form_class = AddCompanyForm
    success_url = reverse_lazy('companies:index')
    object_list = Company.objects.all()

    def form_valid(self, form):
        user, created = User.objects.get_or_create(username=form.cleaned_data['username'],
                                                   email=form.cleaned_data['email'])
        user.set_password(form.cleaned_data['password'])
        user.save()
        if created:
            address = Address(label=form.cleaned_data['label'], city=form.cleaned_data['city'],
                              area=form.cleaned_data['area'], long=form.cleaned_data['longitude'],
                              lat=form.cleaned_data['latitude'], country=form.cleaned_data['country'])
            address.save()

            company = Company(owner=user, name=form.cleaned_data['name'],
                              phone_number=form.cleaned_data['phone_number'], logo=form.cleaned_data['logo'],
                              address=address, water_source=form.cleaned_data['water_source'])
            company.save()
        return super().form_valid(form)
</code>```

form.py

```<code>class AddCompanyForm(forms.ModelForm):
    """
    Add company model form
    """
    name = forms.CharField(required=True)
    password = forms.CharField(widget=forms.PasswordInput())
    logo = forms.ImageField(required=False)
    phone_number = forms.CharField(widget=forms.NumberInput())
    label = forms.CharField(max_length=20)
    country = forms.ModelChoiceField(queryset=Country.objects.all())
    city = forms.ModelChoiceField(queryset=City.objects.all())
    area = forms.ModelChoiceField(queryset=Area.objects.all())
    latitude = forms.CharField(max_length=50, required=False)
    longitude = forms.CharField(max_length=50, required=False)
    water_source = forms.ModelChoiceField(queryset=WaterSource.objects.all())

    class Meta:
        model = User
        fields = ['name', 'username', 'email', 'password']

    def __init__(self, *args, **kwargs):
        super(AddCompanyForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_tag = False
        self.layout = Layout(Row(Column('name', css_class='form-group col-md-6 mb-0'),
                                 Column('username', css_class='form-group col-md-6 mb-0'), css_class='form-row'),
                             Row(Column('email', css_class='form-group col-md-6 mb-0'),
                                 Column('password', css_class='form-group col-md-6 mb-0'), css_class='form-row'),
                             Row(Column('phone_number', css_class='form-group col-md-6 mb-0'),
                                 Column('logo', css_class='form-group col-md-6 mb-0'), css_class='form-row'),
                             Row(Column('label', css_class='form-group col'), css_class='form-row'),
                             Row(Column('country', css_class='form-group col'),
                                 Column('city', css_class='form-group col'), Column('area', css_class='form-group col'),
                                 css_class='form-row'), Row(Column('latitude', css_class='form-group col'),
                                                            Column('longitude', css_class='form-group col'),
                                                            css_class='form-row'),
                             Row(Column('water_source', css_class='form-group col'), css_class='form-row'))
        self.helper.layout = self.layout

</code>```

I am trying to put if request.user.is_superuser but it is not working.

Title: django super user premissions

Body:
i want to add if user is super user show companies  and add company anyone can help with what should add in class to do it
this is class code just showing in tepmalte page all comapany and add new company not working

views.py

class Companies(LoginRequiredMixin, FormView, ListView):
    """
    Company add edit delete view
    """
    model = Company
    template_name = 'company/index.html'
    form_class = AddCompanyForm
    success_url = reverse_lazy('companies:index')
    object_list = Company.objects.all()

    def form_valid(self, form):
        user, created = User.objects.get_or_create(username=form.cleaned_data['username'],
                                                   email=form.cleaned_data['email'])
        user.set_password(form.cleaned_data['password'])
        user.save()
        if created:
            address = Address(label=form.cleaned_data['label'], city=form.cleaned_data['city'],
                              area=form.cleaned_data['area'], long=form.cleaned_data['longitude'],
                              lat=form.cleaned_data['latitude'], country=form.cleaned_data['country'])
            address.save()

            company = Company(owner=user, name=form.cleaned_data['name'],
                              phone_number=form.cleaned_data['phone_number'], logo=form.cleaned_data['logo'],
                              address=address, water_source=form.cleaned_data['water_source'])
            company.save()
        return super().form_valid(form)

form.py

class AddCompanyForm(forms.ModelForm):
    """
    Add company model form
    """
    name = forms.CharField(required=True)
    password = forms.CharField(widget=forms.PasswordInput())
    logo = forms.ImageField(required=False)
    phone_number = forms.CharField(widget=forms.NumberInput())
    label = forms.CharField(max_length=20)
    country = forms.ModelChoiceField(queryset=Country.objects.all())
    city = forms.ModelChoiceField(queryset=City.objects.all())
    area = forms.ModelChoiceField(queryset=Area.objects.all())
    latitude = forms.CharField(max_length=50, required=False)
    longitude = forms.CharField(max_length=50, required=False)
    water_source = forms.ModelChoiceField(queryset=WaterSource.objects.all())

    class Meta:
        model = User
        fields = ['name', 'username', 'email', 'password']

    def __init__(self, *args, **kwargs):
        super(AddCompanyForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_tag = False
        self.layout = Layout(Row(Column('name', css_class='form-group col-md-6 mb-0'),
                                 Column('username', css_class='form-group col-md-6 mb-0'), css_class='form-row'),
                             Row(Column('email', css_class='form-group col-md-6 mb-0'),
                                 Column('password', css_class='form-group col-md-6 mb-0'), css_class='form-row'),
                             Row(Column('phone_number', css_class='form-group col-md-6 mb-0'),
                                 Column('logo', css_class='form-group col-md-6 mb-0'), css_class='form-row'),
                             Row(Column('label', css_class='form-group col'), css_class='form-row'),
                             Row(Column('country', css_class='form-group col'),
                                 Column('city', css_class='form-group col'), Column('area', css_class='form-group col'),
                                 css_class='form-row'), Row(Column('latitude', css_class='form-group col'),
                                                            Column('longitude', css_class='form-group col'),
                                                            css_class='form-row'),
                             Row(Column('water_source', css_class='form-group col'), css_class='form-row'))
        self.helper.layout = self.layout

I am trying to put if request.user.is_superuser but it is not working.


问:
Services on the same network cannot be seen by alias, only by ip
I have the following bridge network locally:

$ docker network ls

NETWORK ID     NAME                             DRIVER    SCOPE
08e7e0710fd9   bridge                           bridge    local
```
<p>I have 3 containers linked in this network:</p>
<pre class="lang-bash prettyprint-override"><code>$ docker network inspect bridge

"Containers": {
            "0b76b1bb23bf805b181ee1696d1366f35e5f49df446203deb32f13bd2caaba32": {
                "Name": "local-mysql",
                "EndpointID": "0288da5e7374456d8c877a8230e9515a63799bfe20f1081ac03003cfab8e0f59",
                "MacAddress": "02:42:ac:11:00:03",
                "IPv4Address": "172.17.0.3/16",
                "IPv6Address": ""
            },
            "340c09255c23104e1b52f6b6b2f1adbb4ce6d5a0a139e8ec4ac613198a853022": {
                "Name": "local-app",
                "EndpointID": "dedccf1c9830cb2e28e2ac3e3953c73006e1294b45a3f70475d01a918787c03c",
                "MacAddress": "02:42:ac:11:00:02",
                "IPv4Address": "172.17.0.2/16",
                "IPv6Address": ""
            },
            "ccabe6e1231144b023ddfd49403f63c49de03747ce4c31f8b55533c5b5c69f91": {
                "Name": "local-phpmyadmin",
                "EndpointID": "3f13e0677c07da79df6b7ad32038b437619250c38d4d82656b3aa7dbc0aaebe2",
                "MacAddress": "02:42:ac:11:00:04",
                "IPv4Address": "172.17.0.4/16",
                "IPv6Address": ""
            }
        },
</code>```

I have the following containers running:

$ docker container ps

CONTAINER ID   IMAGE                   COMMAND                  CREATED          STATUS          PORTS                                                                       NAMES
a4395f3e72f6   local-php-app           "docker-php-entrypoi…"   16 minutes ago   Up 16 minutes   0.0.0.0:8080->80/tcp                                                        local-php-app
ccabe6e12311   local-phpmyadmin        "/docker-entrypoint.…"   16 minutes ago   Up 16 minutes   0.0.0.0:3305->80/tcp                                                        local-phpmyadmin
0b76b1bb23bf   local-mysql             "docker-entrypoint.s…"   16 minutes ago   Up 16 minutes   0.0.0.0:3306->3306/tcp, 33060/tcp                                           local-mysql
340c09255c23   local-app               "/core/run.sh"           4 hours ago      Up 26 minutes   0.0.0.0:15384->5005/tcp, 0.0.0.0:20069->8080/tcp, 0.0.0.0:19286->8443/tcp   local-app
```
<p>Python code trying to connect:</p>
<pre class="lang-py prettyprint-override"><code>        mysql_pass = ''
        mysql_endpoint = 'local-mysql:3306'

        mysql_host = mysql_endpoint.split(":")[0]
        mysql_port = int(mysql_endpoint.split(":")[1])
        mysql_db = "localdb"
        mysql_user = 'root'

        db_connection = pymysql.connect(host=mysql_host,
                                        port=mysql_port,
                                        user=mysql_user,
                                        passwd=mysql_pass,
                                        db=mysql_db)
</code>```

So using mysql_endpoint="local-mysql:3306", I get the following error:

```<code>OperationalError
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'local-mysql' ([Errno -2] Name or service not known)")
</code>```

So I decided to get the local-mysql container IP to use directly:

```<code>$ docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 0b76b1bb23bf

172.17.0.3
</code>```

If I change it to mysql_endpoint="172.17.0.3:3306", it works perfectly:

```<code>"Database version: ('8.0.31',)"
</code>```

Why?

The fact that they are all on the same network should already be possible to make the connection using the "service name"?

What's the difference between using "alias" and using IP?

How do I use "links" when I have services with different "docker-compose.yml"?

Body:
I have the following bridge network locally:

$ docker network ls

NETWORK ID     NAME                             DRIVER    SCOPE
08e7e0710fd9   bridge                           bridge    local

I have 3 containers linked in this network:

$ docker network inspect bridge

"Containers": {
            "0b76b1bb23bf805b181ee1696d1366f35e5f49df446203deb32f13bd2caaba32": {
                "Name": "local-mysql",
                "EndpointID": "0288da5e7374456d8c877a8230e9515a63799bfe20f1081ac03003cfab8e0f59",
                "MacAddress": "02:42:ac:11:00:03",
                "IPv4Address": "172.17.0.3/16",
                "IPv6Address": ""
            },
            "340c09255c23104e1b52f6b6b2f1adbb4ce6d5a0a139e8ec4ac613198a853022": {
                "Name": "local-app",
                "EndpointID": "dedccf1c9830cb2e28e2ac3e3953c73006e1294b45a3f70475d01a918787c03c",
                "MacAddress": "02:42:ac:11:00:02",
                "IPv4Address": "172.17.0.2/16",
                "IPv6Address": ""
            },
            "ccabe6e1231144b023ddfd49403f63c49de03747ce4c31f8b55533c5b5c69f91": {
                "Name": "local-phpmyadmin",
                "EndpointID": "3f13e0677c07da79df6b7ad32038b437619250c38d4d82656b3aa7dbc0aaebe2",
                "MacAddress": "02:42:ac:11:00:04",
                "IPv4Address": "172.17.0.4/16",
                "IPv6Address": ""
            }
        },

I have the following containers running:

$ docker container ps

CONTAINER ID   IMAGE                   COMMAND                  CREATED          STATUS          PORTS                                                                       NAMES
a4395f3e72f6   local-php-app           "docker-php-entrypoi…"   16 minutes ago   Up 16 minutes   0.0.0.0:8080->80/tcp                                                        local-php-app
ccabe6e12311   local-phpmyadmin        "/docker-entrypoint.…"   16 minutes ago   Up 16 minutes   0.0.0.0:3305->80/tcp                                                        local-phpmyadmin
0b76b1bb23bf   local-mysql             "docker-entrypoint.s…"   16 minutes ago   Up 16 minutes   0.0.0.0:3306->3306/tcp, 33060/tcp                                           local-mysql
340c09255c23   local-app               "/core/run.sh"           4 hours ago      Up 26 minutes   0.0.0.0:15384->5005/tcp, 0.0.0.0:20069->8080/tcp, 0.0.0.0:19286->8443/tcp   local-app

Python code trying to connect:

        mysql_pass = ''
        mysql_endpoint = 'local-mysql:3306'

        mysql_host = mysql_endpoint.split(":")[0]
        mysql_port = int(mysql_endpoint.split(":")[1])
        mysql_db = "localdb"
        mysql_user = 'root'

        db_connection = pymysql.connect(host=mysql_host,
                                        port=mysql_port,
                                        user=mysql_user,
                                        passwd=mysql_pass,
                                        db=mysql_db)

So using mysql_endpoint="local-mysql:3306", I get the following error:

OperationalError
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'local-mysql' ([Errno -2] Name or service not known)")

So I decided to get the local-mysql container IP to use directly:

$ docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 0b76b1bb23bf

172.17.0.3

If I change it to mysql_endpoint="172.17.0.3:3306", it works perfectly:

"Database version: ('8.0.31',)"

Why?

The fact that they are all on the same network should already be possible to make the connection using the "service name"?

What's the difference between using "alias" and using IP?

How do I use "links" when I have services with different "docker-compose.yml"?


问:
React native: KeyboardAvoiding footer with multiline TextInput that will expand
I'm building an app in React Native, aiming to be used on iOS and in the future Android.

To start, I'm trying to build a simple UI: a header at the top (avoiding the notch), a footer at the bottom, and a multiline input that expands to fill however much vertical space is left. I would like the footer to move up when the keyboard is showing, so that it's right above the keyboard.

In terms of components, I have:

```<code><SafeAreaView>
    <KeyboardAvoidingView>
        <Header />
        <View>
            <TextInput multiline numberOfLines={#}/>
        </View>
        <Footer />
    </KeyboardAvoidingView>
</SafeAreaView>
</code>```

I'm having trouble accomplishing the desired UI though. Problems include:

I've tried giving Header and Footer flexGrow of 0 and the middle View a flexGrow of 1, but it doesn't cause the middle View to grow vertically

Ideally I would not have to specify how many lines the multiline TextInput is - the user can just keep typing, and if the contents get super long, that input section will scroll

On the web view, I see the middle View and TextInput, but on my phone (via Expo Go), the middle View and TextInput are always completely collapsed unless I explicitly specify a height or flexBasis on one of the two.

Any pointers on what I'm missing?

Body:
I'm building an app in React Native, aiming to be used on iOS and in the future Android.

To start, I'm trying to build a simple UI: a header at the top (avoiding the notch), a footer at the bottom, and a multiline input that expands to fill however much vertical space is left. I would like the footer to move up when the keyboard is showing, so that it's right above the keyboard.

In terms of components, I have:

<SafeAreaView>
    <KeyboardAvoidingView>

        <View>
            <TextInput multiline numberOfLines={#}/>
        </View>

    </KeyboardAvoidingView>
</SafeAreaView>

I'm having trouble accomplishing the desired UI though. Problems include:

I've tried giving Header and Footer flexGrow of 0 and the middle View a flexGrow of 1, but it doesn't cause the middle View to grow vertically

Ideally I would not have to specify how many lines the multiline TextInput is - the user can just keep typing, and if the contents get super long, that input section will scroll

On the web view, I see the middle View and TextInput, but on my phone (via Expo Go), the middle View and TextInput are always completely collapsed unless I explicitly specify a height or flexBasis on one of the two.

Any pointers on what I'm missing?