1 /* Copyright 2002-2025 CS GROUP
2 * Licensed to CS GROUP (CS) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * CS licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.orekit.estimation.common;
19
20 import org.orekit.estimation.measurements.EstimatedMeasurement;
21 import org.orekit.estimation.measurements.ObservedMeasurement;
22
23 /** Evaluation counting.
24 * @param T type of mesurement
25 * @author Luc Maisonobe
26 */
27 class EvaluationCounter<T extends ObservedMeasurement<T>> implements EvaluationLogger<T> {
28
29 /** Total number of measurements. */
30 private int total;
31
32 /** Number of active (i.e. positive weight) measurements. */
33 private int active;
34
35 /** {@inheritDoc} */
36 @Override
37 public void log(final EstimatedMeasurement<T> evaluation) {
38 ++total;
39 if (evaluation.getStatus() == EstimatedMeasurement.Status.PROCESSED) {
40 ++active;
41 }
42 }
43
44 /** Format an active/total count.
45 * @param size field minimum size
46 * @return formatted count
47 */
48 public String format(final int size) {
49 final StringBuilder builder = new StringBuilder();
50 builder.append(active);
51 builder.append('/');
52 builder.append(total);
53 while (builder.length() < size) {
54 if (builder.length() % 2 == 0) {
55 builder.insert(0, ' ');
56 } else {
57 builder.append(' ');
58 }
59 }
60 return builder.toString();
61 }
62
63 }