private void parse() {
        do {
            char ch = getNextChar();
            if (isCompassDirection(ch) && nsew == 0) {
                if (ch == 'n' || ch =='N') {
                    nsew = 'n';
                } else if (ch == 's' || ch == 'S') {
                    nsew = 's';
                } else if (ch == 'e' || ch == 'E') {
                    nsew = 'e';
                } else if (ch == 'w' || ch == 'W') {
                    nsew = 'w';
                }
                lastNumStartPos = 0;
            }
            if (ch == '=' || ch == ':') {
                if (nsew != 0) {
                    lastNumStartPos = pos;
                }
            }
            if (ch == ',' || ch == 0 || ch == ' ') {
                if (nsew != 0 && lastNumStartPos > 0) {
                    String sub = parseString.substring(lastNumStartPos, pos-1);
                    try {
                        double v = Double.parseDouble(sub);
                        if (nsew == 'n') {
                            if (doneN) {
                                throw new IllegalArgumentException("multiple limits for 'n' boundary");
                            }
                            n = v;
                            doneN = true;
                        } else if (nsew == 's') {
                            if (doneS) {
                                throw new IllegalArgumentException("multiple limits for 's' boundary");
                            }
                            s = v;
                            doneS = true;
                        } else if (nsew == 'e') {
                            if (doneE) {
                                throw new IllegalArgumentException("multiple limits for 'e' boundary");
                            }
                            e = v;
                            doneE = true;
                        } else if (nsew == 'w') {
                            if (doneW) {
                                throw new IllegalArgumentException("multiple limits for 'w' boundary");
                            }
                            w = v;
                            doneW = true;
                        }
                    } catch (NumberFormatException e) {
                        throw new IllegalArgumentException("Could not parse "+nsew+" limit '"+sub+"' as a number");
                    }
                    nsew = 0;
                }
            }
        } while (pos <= len);

        if (doneN && doneS && doneE && doneW) {
            return;
        } else {
            throw new IllegalArgumentException("Missing bounding box limits, n="+doneN+" s="+doneS+" e="+doneE+" w="+doneW);
        }
    }
parse the given string as a bounding box and return a parser object with parsed coordinates in member variables
@throws IllegalArgumentException if the input is malformed in any way
vespajlib/src/main/java/com/yahoo/geo/BoundingBoxParser.java