Search in sources :

Example 6 with Reference

use of de.lmu.ifi.dbs.elki.utilities.documentation.Reference in project elki by elki-project.

the class DocumentReferences method inspectClass.

private static void inspectClass(final Class<?> cls, List<Pair<Reference, TreeSet<Object>>> refs, Map<Reference, TreeSet<Object>> map) {
    if (cls.getSimpleName().equals("package-info")) {
        return;
    }
    try {
        if (cls.isAnnotationPresent(Reference.class)) {
            Reference ref = cls.getAnnotation(Reference.class);
            addReference(cls, ref, refs, map);
        }
        // Inner classes
        for (Class<?> c2 : cls.getDeclaredClasses()) {
            inspectClass(c2, refs, map);
        }
        for (Method m : cls.getDeclaredMethods()) {
            if (m.isAnnotationPresent(Reference.class)) {
                addReference(cls, m.getAnnotation(Reference.class), refs, map);
            }
        }
        for (Field f : cls.getDeclaredFields()) {
            if (f.isAnnotationPresent(Reference.class)) {
                addReference(cls, f.getAnnotation(Reference.class), refs, map);
            }
        }
    } catch (Error e) {
        LOG.warning("Exception in finding references for class " + cls.getCanonicalName() + ": " + e, e);
    }
}
Also used : Field(java.lang.reflect.Field) Reference(de.lmu.ifi.dbs.elki.utilities.documentation.Reference) Method(java.lang.reflect.Method)

Example 7 with Reference

use of de.lmu.ifi.dbs.elki.utilities.documentation.Reference in project elki by elki-project.

the class DocumentReferences method documentReferences.

private static Document documentReferences(List<Pair<Reference, TreeSet<Object>>> refs) throws IOException {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder;
    try {
        builder = factory.newDocumentBuilder();
    } catch (ParserConfigurationException e1) {
        throw new IOException(e1);
    }
    DOMImplementation impl = builder.getDOMImplementation();
    Document htmldoc = impl.createDocument(HTMLUtil.HTML_NAMESPACE, HTMLUtil.HTML_HTML_TAG, null);
    // head
    Element head = htmldoc.createElement(HTMLUtil.HTML_HEAD_TAG);
    htmldoc.getDocumentElement().appendChild(head);
    // body
    Element body = htmldoc.createElement(HTMLUtil.HTML_BODY_TAG);
    htmldoc.getDocumentElement().appendChild(body);
    // modification warnings
    head.appendChild(htmldoc.createComment(MODIFICATION_WARNING));
    body.appendChild(htmldoc.createComment(MODIFICATION_WARNING));
    // meta with charset information
    {
        Element meta = htmldoc.createElement(HTMLUtil.HTML_META_TAG);
        meta.setAttribute(HTMLUtil.HTML_HTTP_EQUIV_ATTRIBUTE, HTMLUtil.HTML_HTTP_EQUIV_CONTENT_TYPE);
        meta.setAttribute(HTMLUtil.HTML_CONTENT_ATTRIBUTE, HTMLUtil.CONTENT_TYPE_HTML_UTF8);
        head.appendChild(meta);
    }
    // stylesheet
    {
        Element css = htmldoc.createElement(HTMLUtil.HTML_LINK_TAG);
        css.setAttribute(HTMLUtil.HTML_REL_ATTRIBUTE, HTMLUtil.HTML_REL_STYLESHEET);
        css.setAttribute(HTMLUtil.HTML_TYPE_ATTRIBUTE, HTMLUtil.CONTENT_TYPE_CSS);
        css.setAttribute(HTMLUtil.HTML_HREF_ATTRIBUTE, CSSFILE);
        head.appendChild(css);
    }
    // title
    {
        Element title = htmldoc.createElement(HTMLUtil.HTML_TITLE_TAG);
        title.setTextContent("ELKI references overview.");
        head.appendChild(title);
    }
    // Heading
    {
        Element h1 = htmldoc.createElement(HTMLUtil.HTML_H1_TAG);
        h1.setTextContent("ELKI references overview:");
        body.appendChild(h1);
    }
    // Main definition list
    Element maindl = htmldoc.createElement(HTMLUtil.HTML_DL_TAG);
    body.appendChild(maindl);
    for (Pair<Reference, TreeSet<Object>> pair : refs) {
        // DT = definition term
        Element classdt = htmldoc.createElement(HTMLUtil.HTML_DT_TAG);
        // Anchor for references
        {
            boolean first = true;
            for (Object o : pair.second) {
                if (!first) {
                    classdt.appendChild(htmldoc.createTextNode(", "));
                }
                if (o instanceof Class<?>) {
                    Class<?> cls = (Class<?>) o;
                    Element classan = htmldoc.createElement(HTMLUtil.HTML_A_TAG);
                    classan.setAttribute(HTMLUtil.HTML_NAME_ATTRIBUTE, cls.getName());
                    classdt.appendChild(classan);
                    // Link back to original class
                    Element classa = htmldoc.createElement(HTMLUtil.HTML_A_TAG);
                    classa.setAttribute(HTMLUtil.HTML_HREF_ATTRIBUTE, linkForClassName(cls.getName()));
                    classa.setTextContent(cls.getName());
                    classdt.appendChild(classa);
                } else if (o instanceof Package) {
                    Package pkg = (Package) o;
                    Element classan = htmldoc.createElement(HTMLUtil.HTML_A_TAG);
                    classan.setAttribute(HTMLUtil.HTML_NAME_ATTRIBUTE, pkg.getName());
                    classdt.appendChild(classan);
                    // Link back to original class
                    Element classa = htmldoc.createElement(HTMLUtil.HTML_A_TAG);
                    classa.setAttribute(HTMLUtil.HTML_HREF_ATTRIBUTE, linkForPackageName(pkg.getName()));
                    classa.setTextContent(pkg.getName());
                    classdt.appendChild(classa);
                }
                first = false;
            }
        }
        maindl.appendChild(classdt);
        // DD = definition description
        Element classdd = htmldoc.createElement(HTMLUtil.HTML_DD_TAG);
        maindl.appendChild(classdd);
        {
            Reference ref = pair.first;
            // Prefix
            if (ref.prefix().length() > 0) {
                Element prediv = htmldoc.createElement(HTMLUtil.HTML_DIV_TAG);
                prediv.setTextContent(ref.prefix());
                classdd.appendChild(prediv);
            }
            // Authors
            Element authorsdiv = htmldoc.createElement(HTMLUtil.HTML_DIV_TAG);
            authorsdiv.setTextContent(ref.authors());
            classdd.appendChild(authorsdiv);
            // Title
            Element titlediv = htmldoc.createElement(HTMLUtil.HTML_DIV_TAG);
            Element titleb = htmldoc.createElement(HTMLUtil.HTML_B_TAG);
            titleb.setTextContent(ref.title());
            titlediv.appendChild(titleb);
            classdd.appendChild(titlediv);
            // Booktitle
            if (ref.booktitle().length() > 0) {
                Element booktitlediv = htmldoc.createElement(HTMLUtil.HTML_DIV_TAG);
                booktitlediv.setTextContent("In: " + ref.booktitle());
                if (ref.booktitle().startsWith("Online:")) {
                    booktitlediv.setTextContent(ref.booktitle());
                }
                classdd.appendChild(booktitlediv);
            }
            // URL
            if (ref.url().length() > 0) {
                Element urldiv = htmldoc.createElement(HTMLUtil.HTML_DIV_TAG);
                Element urla = htmldoc.createElement(HTMLUtil.HTML_A_TAG);
                urla.setAttribute(HTMLUtil.HTML_HREF_ATTRIBUTE, ref.url());
                urla.setTextContent(ref.url());
                urldiv.appendChild(urla);
                classdd.appendChild(urldiv);
            }
        }
    }
    return htmldoc;
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) Reference(de.lmu.ifi.dbs.elki.utilities.documentation.Reference) Element(org.w3c.dom.Element) DOMImplementation(org.w3c.dom.DOMImplementation) IOException(java.io.IOException) Document(org.w3c.dom.Document) DocumentBuilder(javax.xml.parsers.DocumentBuilder) TreeSet(java.util.TreeSet) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 8 with Reference

use of de.lmu.ifi.dbs.elki.utilities.documentation.Reference in project elki by elki-project.

the class SphereUtil method latlngMinDistRad.

/**
 * Point to rectangle minimum distance.
 *
 * Complexity:
 * <ul>
 * <li>Trivial cases (on longitude slice): no trigonometric functions.</li>
 * <li>Corner case: 3/4 trig + 4-5 trig, 1 sqrt</li>
 * <li>Cross-track case: 4+2 trig</li>
 * </ul>
 *
 * <b>Important:</b> Rectangles must be in -pi:+pi, and must have min &lt;
 * max, so they cannot cross the date line.
 *
 * Reference:
 * <p>
 * Erich Schubert, Arthur Zimek and Hans-Peter Kriegel<br />
 * Geodetic Distance Queries on R-Trees for Indexing Geographic Data<br />
 * 13th Int. Symposium on Advances in Spatial and Temporal Databases
 * </p>
 *
 * @param plat Latitude of query point.
 * @param plng Longitude of query point.
 * @param rminlat Min latitude of rectangle.
 * @param rminlng Min longitude of rectangle.
 * @param rmaxlat Max latitude of rectangle.
 * @param rmaxlng Max longitude of rectangle.
 * @return Distance on unit sphere.
 */
@// 
Reference(// 
authors = "Erich Schubert, Arthur Zimek and Hans-Peter Kriegel", // 
title = "Geodetic Distance Queries on R-Trees for Indexing Geographic Data", // 
booktitle = "13th Int. Symposium on Advances in Spatial and Temporal Databases", url = "http://dx.doi.org/10.1007/978-3-642-40235-7_9")
public static double latlngMinDistRad(double plat, double plng, double rminlat, double rminlng, double rmaxlat, double rmaxlng) {
    // Degenerate rectangles:
    if ((rminlat >= rmaxlat) && (rminlng >= rmaxlng)) {
        return cosineOrHaversineRad(rminlat, rminlng, plat, plng);
    }
    // The simplest case is when the query point is in the same "slice":
    if (rminlng <= plng && plng <= rmaxlng) {
        return // Inside
        (rminlat <= plat && plat <= rmaxlat) ? // Inside
        0 : // S, N
        (plat < rminlat) ? rminlat - plat : plat - rmaxlat;
    }
    // Determine whether going east or west is shorter.
    double lngE = rminlng - plng, lngW = plng - rmaxlng;
    // Ensure delta to be in 0 to 2pi.
    lngE = lngE >= 0 ? lngE : lngE + TWOPI;
    lngW = lngW >= 0 ? lngW : lngW + TWOPI;
    // Case distinction east or west:
    final double lngD = (lngE <= lngW) ? lngE : lngW;
    final double rlng = (lngE <= lngW) ? rminlng : rmaxlng;
    // To return cosine
    final DoubleWrapper tmp = new DoubleWrapper();
    final double slngD = sinAndCos(lngD, tmp), clngD = tmp.value;
    final double tlatQ = tan(plat);
    if (lngD >= HALFPI) {
        // XTD disappears at 90°
        return cosineOrHaversineRad(// 
        plat, // 
        plng, // N/S
        tlatQ >= tan((rmaxlat + rminlat) * .5) * clngD ? rmaxlat : rminlat, rlng);
    }
    if (tlatQ >= tan(rmaxlat) * clngD) {
        // North corner
        return cosineOrHaversineRad(plat, plng, rmaxlat, rlng);
    }
    if (tlatQ <= tan(rminlat) * clngD) {
        // South corner
        return cosineOrHaversineRad(plat, plng, rminlat, rlng);
    }
    // Cross-track-distance to longitude line.
    return asin(cos(plat) * slngD);
}
Also used : DoubleWrapper(net.jafama.DoubleWrapper) Reference(de.lmu.ifi.dbs.elki.utilities.documentation.Reference)

Example 9 with Reference

use of de.lmu.ifi.dbs.elki.utilities.documentation.Reference in project elki by elki-project.

the class SphereUtil method ellipsoidVincentyFormulaRad.

/**
 * Compute the approximate great-circle distance of two points.
 *
 * Reference:
 * <p>
 * T. Vincenty<br />
 * Direct and inverse solutions of geodesics on the ellipsoid with application
 * of nested equations<br />
 * Survey review 23 176, 1975
 * </p>
 *
 * @param f Ellipsoid flattening
 * @param lat1 Latitude of first point in degree
 * @param lon1 Longitude of first point in degree
 * @param lat2 Latitude of second point in degree
 * @param lon2 Longitude of second point in degree
 * @return Distance for a minor axis of 1.
 */
@// 
Reference(// 
authors = "T. Vincenty", // 
title = "Direct and inverse solutions of geodesics on the ellipsoid with application of nested equations", booktitle = "Survey review 23 176, 1975", url = "http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf")
public static double ellipsoidVincentyFormulaRad(double f, double lat1, double lon1, double lat2, double lon2) {
    final double dlon = (lon2 >= lon1) ? (lon2 - lon1) : (lon1 - lon2);
    // = 1 - (a-b)/a = b/a
    final double onemf = 1 - f;
    // Second eccentricity squared
    // = a/b
    final double a_b = 1. / onemf;
    // (a^2-b^2)/(b^2)
    final double ecc2 = (a_b + 1) * (a_b - 1);
    // Reduced latitudes:
    final double u1 = atan(onemf * tan(lat1));
    final double u2 = atan(onemf * tan(lat2));
    // Trigonometric values
    // To return cosine
    final DoubleWrapper tmp = new DoubleWrapper();
    final double su1 = sinAndCos(u1, tmp), cu1 = tmp.value;
    final double su2 = sinAndCos(u2, tmp), cu2 = tmp.value;
    // Eqn (13) - initial value
    double lambda = dlon;
    for (int i = 0; ; i++) {
        final double slon = sinAndCos(lambda, tmp), clon = tmp.value;
        // Eqn (14) - \sin \sigma
        final double term1 = cu2 * slon, term2 = cu1 * su2 - su1 * cu2 * clon;
        final double ssig = sqrt(term1 * term1 + term2 * term2);
        // Eqn (15) - \cos \sigma
        final double csig = su1 * su2 + cu1 * cu2 * clon;
        // Two identical points?
        if (!(ssig > 0)) {
            return 0.;
        }
        // Eqn (16) - \sigma from \tan \sigma
        final double sigma = atan2(ssig, csig);
        // Eqn (17) - \sin \alpha, and this way \cos^2 \alpha
        final double salp = cu1 * cu2 * slon / ssig;
        final double c2alp = (1. + salp) * (1. - salp);
        // Eqn (18) - \cos 2 \sigma_m
        final double ctwosigm = (Math.abs(c2alp) > 0) ? csig - 2.0 * su1 * su2 / c2alp : 0.;
        final double c2twosigm = ctwosigm * ctwosigm;
        // Eqn (10) - C
        final double cc = f * .0625 * c2alp * (4.0 + f * (4.0 - 3.0 * c2alp));
        // Eqn (11) - new \lambda
        final double prevlambda = lambda;
        lambda = dlon + // 
        (1.0 - cc) * f * salp * (sigma + cc * ssig * (ctwosigm + cc * csig * (-1.0 + 2.0 * c2twosigm)));
        // Check for convergence:
        if (Math.abs(prevlambda - lambda) < PRECISION || i >= MAX_ITER) {
            // TODO: what is the proper result to return on MAX_ITER (antipodal
            // points)?
            // Definition of u^2, rewritten to use second eccentricity.
            final double usq = c2alp * ecc2;
            // Eqn (3) - A
            final double aa = 1.0 + usq / 16384.0 * (4096.0 + usq * (-768.0 + usq * (320.0 - 175.0 * usq)));
            // Eqn (4) - B
            final double bb = usq / 1024.0 * (256.0 + usq * (-128.0 + usq * (74.0 - 47.0 * usq)));
            // Eqn (6) - \Delta \sigma
            final double dsig = bb * ssig * (ctwosigm + .25 * bb * (// 
            csig * (-1.0 + 2.0 * c2twosigm) - ONE_SIXTH * bb * ctwosigm * (-3.0 + 4.0 * ssig * ssig) * (-3.0 + 4.0 * c2twosigm)));
            // Eqn (19) - s
            return aa * (sigma - dsig);
        }
    }
}
Also used : DoubleWrapper(net.jafama.DoubleWrapper) Reference(de.lmu.ifi.dbs.elki.utilities.documentation.Reference)

Example 10 with Reference

use of de.lmu.ifi.dbs.elki.utilities.documentation.Reference in project elki by elki-project.

the class SphereUtil method sphericalVincentyFormulaRad.

/**
 * Compute the approximate great-circle distance of two points.
 *
 * Uses Vincenty's Formula for the spherical case, which does not require
 * iterations.
 *
 * Complexity: 7 trigonometric functions, 1 sqrt.
 *
 * Reference:
 * <p>
 * T. Vincenty<br />
 * Direct and inverse solutions of geodesics on the ellipsoid with application
 * of nested equations<br />
 * Survey review 23 176, 1975
 * </p>
 *
 * @param lat1 Latitude of first point in degree
 * @param lon1 Longitude of first point in degree
 * @param lat2 Latitude of second point in degree
 * @param lon2 Longitude of second point in degree
 * @return Distance on unit sphere
 */
@// 
Reference(// 
authors = "T. Vincenty", // 
title = "Direct and inverse solutions of geodesics on the ellipsoid with application of nested equations", // 
booktitle = "Survey review 23 176, 1975", url = "http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf")
public static double sphericalVincentyFormulaRad(double lat1, double lon1, double lat2, double lon2) {
    // Half delta longitude.
    final double dlnh = (lon1 > lon2) ? (lon1 - lon2) : (lon2 - lon1);
    // Spherical special case of Vincenty's formula - no iterations needed
    // To return cosine
    final DoubleWrapper tmp = new DoubleWrapper();
    final double slat1 = sinAndCos(lat1, tmp), clat1 = tmp.value;
    final double slat2 = sinAndCos(lat2, tmp), clat2 = tmp.value;
    final double slond = sinAndCos(dlnh, tmp), clond = tmp.value;
    final double a = clat2 * slond;
    final double b = (clat1 * slat2) - (slat1 * clat2 * clond);
    return atan2(sqrt(a * a + b * b), slat1 * slat2 + clat1 * clat2 * clond);
}
Also used : DoubleWrapper(net.jafama.DoubleWrapper) Reference(de.lmu.ifi.dbs.elki.utilities.documentation.Reference)

Aggregations

Reference (de.lmu.ifi.dbs.elki.utilities.documentation.Reference)10 DoubleWrapper (net.jafama.DoubleWrapper)3 DBIDIter (de.lmu.ifi.dbs.elki.database.ids.DBIDIter)2 DBIDs (de.lmu.ifi.dbs.elki.database.ids.DBIDs)2 DistanceBasedAlgorithm (de.lmu.ifi.dbs.elki.algorithm.DistanceBasedAlgorithm)1 DWOF (de.lmu.ifi.dbs.elki.algorithm.outlier.DWOF)1 FastABOD (de.lmu.ifi.dbs.elki.algorithm.outlier.anglebased.FastABOD)1 KNNDD (de.lmu.ifi.dbs.elki.algorithm.outlier.distance.KNNDD)1 KNNOutlier (de.lmu.ifi.dbs.elki.algorithm.outlier.distance.KNNOutlier)1 KNNSOS (de.lmu.ifi.dbs.elki.algorithm.outlier.distance.KNNSOS)1 KNNWeightOutlier (de.lmu.ifi.dbs.elki.algorithm.outlier.distance.KNNWeightOutlier)1 LocalIsolationCoefficient (de.lmu.ifi.dbs.elki.algorithm.outlier.distance.LocalIsolationCoefficient)1 ODIN (de.lmu.ifi.dbs.elki.algorithm.outlier.distance.ODIN)1 IDOS (de.lmu.ifi.dbs.elki.algorithm.outlier.intrinsic.IDOS)1 ISOS (de.lmu.ifi.dbs.elki.algorithm.outlier.intrinsic.ISOS)1 IntrinsicDimensionalityOutlier (de.lmu.ifi.dbs.elki.algorithm.outlier.intrinsic.IntrinsicDimensionalityOutlier)1 COF (de.lmu.ifi.dbs.elki.algorithm.outlier.lof.COF)1 INFLO (de.lmu.ifi.dbs.elki.algorithm.outlier.lof.INFLO)1 KDEOS (de.lmu.ifi.dbs.elki.algorithm.outlier.lof.KDEOS)1 LDF (de.lmu.ifi.dbs.elki.algorithm.outlier.lof.LDF)1