/**
   * @param wfsClient
   * @throws NoSuchAuthorityCodeException
   * @throws FactoryException
   * @throws IOException
   * @throws IndexOutOfBoundsException
   * @throws ParseException
   */
  public OsmInspectorLayer(GeoFabrikWFSClient wfsClient, ProgressMonitor monitor)
      throws NoSuchAuthorityCodeException, FactoryException, IOException, IndexOutOfBoundsException,
          ParseException {
    super("OsmInspector");

    arrFeatures = new ArrayList<>();
    osmiBugInfo = new LinkedHashMap<>();
    selectGeomType = new ArrayList<>();

    // Step 3 - discovery; enhance to iterate over all types with bounds

    String typeNames[] = wfsClient.getTypeNames();
    renderer = new StreamingRenderer();
    CRS.decode(Main.getProjection().toCode());
    crsOSMI = CRS.decode("EPSG:4326");
    content = new MapContent(crsOSMI);

    selectGeomType.add(GeomType.POINT);
    for (int idx = 1; idx < typeNames.length; ++idx) {
      String typeName = typeNames[idx];
      Set<FeatureId> selectedFeatures = new HashSet<>();

      FeatureCollection<SimpleFeatureType, SimpleFeature> features =
          wfsClient.getFeatures(typeName, monitor);
      setGeometry(selectGeomType, typeName);

      Main.info("Osm Inspector Features size: " + features.size());
      Style style = createDefaultStyle(idx, selectedFeatures);

      OSMIFeatureTracker tracker = new OSMIFeatureTracker(features);
      arrFeatures.add(tracker);
      FeatureIterator<SimpleFeature> it = tracker.getFeatures().features();

      while (it.hasNext()) {
        BugInfo theInfo = new BugInfo(it.next(), osmiBugInfo.size());
        osmiBugInfo.put(theInfo, theInfo.bugId);
      }

      content.addLayer(new FeatureLayer(tracker.getFeatures(), style));
    }

    osmiIndex = new BugIndex(osmiBugInfo);
    content.setTitle("Osm Inspector Errors");
    renderer.setMapContent(content);
    bIsChanged = true;

    // finally initialize the dialog
    dialog = new OsmInspectorDialog(this);
    this.updateView();
  }
Esempio n. 2
0
  /** The constructor. */
  public ViewTest() {
    // Create a map content and add our shapefile to it
    map = new MapContent();
    map.setTitle("simple map content");

    // hey, try for an image aswell
    String path = "/Users/ian/Desktop/ukrasterchart/2_BRITISH_ISLES.tif";
    File chartFile = new File(path);
    if (!chartFile.exists()) System.err.println("CANNOT FILE THE CHART FILE!!!");

    WorldImageFormat format = new WorldImageFormat();
    AbstractGridCoverage2DReader tiffReader = format.getReader(chartFile);
    if (tiffReader != null) {
      StyleFactoryImpl sf = new StyleFactoryImpl();
      RasterSymbolizer symbolizer = sf.getDefaultRasterSymbolizer();
      Style defaultStyle = SLD.wrapSymbolizers(symbolizer);

      GeneralParameterValue[] params = null;

      GridReaderLayer res = new GridReaderLayer(tiffReader, defaultStyle, params);
      map.addLayer(res);
    }

    try {
      URL url = GtActivator.getDefault().getBundle().getEntry("data/50m_admin_0_countries.shp");
      String filePath = FileLocator.resolve(url).getFile();
      File file = new File(filePath);
      if (!file.exists()) System.err.println("can't find file!!!");
      FileDataStore store = FileDataStoreFinder.getDataStore(file);
      if (store != null) {
        SimpleFeatureSource featureSource = store.getFeatureSource();

        Style style = SLD.createSimpleStyle(featureSource.getSchema());
        Layer layer = new FeatureLayer(featureSource, style);
        map.addLayer(layer);
      }

    } catch (IOException e) {

    }
    //
  }
Esempio n. 3
0
  private void configureDisplay() {
    content = new MapContent();
    mapPane = new JMapPane(content);
    mapPane.setEnabled(true);
    content.setTitle("GIS APPLICATION");
    mapPane.setToolTipText("Map Area");
    this.setMapContent(content);

    // Create Buttons

    printBtn = new JButton("Print");

    refreshBtn = new JButton("Reset");
    refreshBtn.setToolTipText("Reset layout of window");

    queryBtn = new JButton("Query");

    // Main Panel
    mainPanel = new JPanel();
    Container contentPane = this.getContentPane();

    contentPane.setLayout(new BorderLayout());
    contentPane.add(mainPanel, BorderLayout.SOUTH);

    this.setTitle("GIS Application");
    this.enableToolBar(true);
    this.enableStatusBar(true);
    this.enableLayerTable(true);

    JToolBar toolbar = this.getToolBar();
    toolbar.addSeparator();
    toolbar.add(refreshBtn);
    toolbar.addSeparator();
    // toolbar.add(printBtn);
    toolbar.add(queryBtn);

    //		JButton distance = new JButton("Distance");
    //        toolbar.add(distance);
    //        distance.addActionListener(new ActionListener() {
    //
    //            public void actionPerformed(ActionEvent e) {
    //                distanceflag = true;
    //                distance_and_scalefalg = true;
    //                dis = 0.0;
    //                numberofpoint = 0;
    //                final JFrame ftemp = new JFrame("Distance");
    //                final JLabel flabel = new JLabel();
    //                String step = "To mesuare Distance between two points: \n (1)-Press Mouse Left
    // button on start point. \n (2)-Press Mouse Left button on destination point. \n (3)-For new
    // session press mouse right button.";
    //                JOptionPane.showMessageDialog(null, step);
    //                getMapPane().setCursorTool(
    //                        new CursorTool() {
    //
    //                            private int x1,px1,py1,y1,lx1,ly1,x2,y2,px2,py2;
    //							private double tempdistance;
    //							private int tnumberofpixel;
    //							private int lineincentimeter;
    //							private double scale;
    //
    //							@Override
    //                            public void onMouseClicked(MapMouseEvent ev) {
    //                                if (SwingUtilities.isLeftMouseButton(ev)) {
    //                                    if (distanceflag == true) {
    //                                        distanceflag = false;
    //                                        x1 = ev.getMapPosition().getX();
    //                                        px1 = ev.getX();
    //                                        py1 = ev.getY();
    //                                        y1 = ev.getMapPosition().getY();
    //                                        lx1 = ev.getXOnScreen();
    //                                        ly1 = ev.getYOnScreen();
    //                                    } else {
    //                                        String str;
    //                                        //JFrame ftemp=new JFrame("Distance");
    //                                        ftemp.setVisible(false);
    //                                        Graphics g = getGraphics();
    //                                        //Graphics scaleg=scalepanel.getGraphics();
    //
    //                                        g.drawLine(lx1, ly1, ev.getXOnScreen(),
    // ev.getYOnScreen());
    //                                        lx1 = ev.getXOnScreen();
    //                                        ly1 = ev.getYOnScreen();
    //                                        x2 = ev.getMapPosition().getX();
    //                                        y2 = ev.getMapPosition().getY();
    //                                        px2 = ev.getX();
    //                                        py2 = ev.getY();
    //                                        dis = dis + Math.sqrt(Math.pow(x1 - x2, 2) +
    // Math.pow(y1 - y2, 2));
    ////                                        tempdistance=dis;
    //                                        numberofpoint += Math.sqrt(Math.pow(px1 - px2, 2) +
    // Math.pow(py1 - py2, 2));
    //                                        System.out.println("numberofpoint = " +
    // numberofpoint);
    //                                        if (distance_and_scalefalg == true) {
    //                                            distance_and_scalefalg = false;
    //                                            tempdistance = dis;
    //                                            tnumberofpixel = numberofpoint;
    //                                            lineincentimeter = tnumberofpixel / 28;
    //                                            scale = tempdistance / lineincentimeter;
    //                                        }
    ////
    //                                        System.out.println("lineincentimeter = " +
    // lineincentimeter);
    //                                        x1 = ev.getMapPosition().getX();
    //                                        y1 = ev.getMapPosition().getY();
    //                                        px1 = ev.getX();
    //                                        py1 = ev.getY();
    //                                        System.out.println("x1=" + x1 + "  " + "y1=" + y1);
    //                                        System.out.println("x2=" + x2 + "  " + "y2=" + y2);
    //                                        System.out.println("distance=" + dis + " Meters");
    //                                        scalevalue.setVisible(true);
    //                                        scalevalue.setText("Scale :  1 cm = " + scale + "
    // Meters");
    //                                        toolbar.add(scalevalue, BorderLayout.EAST);
    //                                        flabel.setText("Distance = " + dis + " Meters");
    //                                        JPanel fpanel = new JPanel(new FlowLayout());
    //                                        JButton meterbtn = new JButton("Meters");
    //                                        JButton kmbtn = new JButton("KiloMeters");
    //                                        JButton milebtn = new JButton("Miles");
    //                                        JButton yardbtn = new JButton("Yards");
    //                                        meterbtn.addActionListener(new ActionListener() {
    //
    //                                            public void actionPerformed(ActionEvent e) {
    //                                                flabel.setText("Distance = " + dis + "
    // Meters");
    //                                                scalevalue.setText("Scale :  1 cm = " + scale
    // + " Meters");
    //                                            }
    //                                        });
    //
    //                                        kmbtn.addActionListener(new ActionListener() {
    //
    //                                            public void actionPerformed(ActionEvent e) {
    //                                                flabel.setText("Distance = " + dis / 1000 + "
    // KiloMeters");
    //                                                scalevalue.setText("Scale :  1 cm = " + scale
    // / 1000 + " Km");
    //                                            }
    //                                        });
    //
    //                                        milebtn.addActionListener(new ActionListener() {
    //
    //                                            public void actionPerformed(ActionEvent e) {
    //                                                flabel.setText("Distance = " + dis * 0.00062 +
    // " Miles");
    //                                                scalevalue.setText("Scale :  1 cm = " + scale
    // * 0.00062 + " Miles");
    //                                            }
    //                                        });
    //
    //
    //                                        yardbtn.addActionListener(new ActionListener() {
    //
    //                                            public void actionPerformed(ActionEvent e) {
    //                                                flabel.setText("Distance = " + dis * 1.094 + "
    // Yards");
    //                                                scalevalue.setText("Scale :  1 cm = " + scale
    // * 1.094 + " Yards");
    //                                            }
    //                                        });
    //
    //                                        fpanel.add(meterbtn);
    //                                        fpanel.add(kmbtn);
    //                                        fpanel.add(milebtn);
    //                                        fpanel.add(yardbtn);
    //                                        ftemp.add(flabel, BorderLayout.CENTER);
    //                                        ftemp.add(fpanel, BorderLayout.SOUTH);
    //                                        ftemp.setSize(400, 200);
    //                                        ftemp.setVisible(true);
    //
    //                                    }
    //                                } else {
    //                                    distanceflag = true;
    //                                    distance_and_scalefalg = true;
    //                                    scalevalue.setVisible(false);
    //                                    dis = 0.0;
    //                                    numberofpoint = 0;
    //                                    setMapContext(context);
    //                                    repaint();
    //                                }
    //                            }
    //                        });
    //            }
    //        });
    this.setJMenuBar(new CustomMenuBar(mapPane));
    this.setExtendedState(MAXIMIZED_BOTH);
    this.setMinimumSize(new Dimension(800, 800));

    this.setIconImage(java.awt.Toolkit.getDefaultToolkit().createImage("res\\img\\icon.png"));
    this.setVisible(true);
  }